ReactOS  0.4.11-dev-946-g431643b
startuppage.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS Applications
3  * LICENSE: LGPL - See COPYING in the top level directory
4  * FILE: base/applications/msconfig_new/startuppage.c
5  * PURPOSE: Startup page message handler
6  * COPYRIGHT: Copyright 2005-2006 Christoph von Wittich <Christoph@ApiViewer.de>
7  *
8  */
9 
10 #include "precomp.h"
11 
15 
18 
21 {
23  TCHAR szTemp[256];
24  DWORD dwStyle;
25 
26  UNREFERENCED_PARAMETER(lParam);
27  UNREFERENCED_PARAMETER(wParam);
28 
29  switch (message) {
30  case WM_INITDIALOG:
31 
32  hStartupListCtrl = GetDlgItem(hDlg, IDC_STARTUP_LIST);
33  hStartupDialog = hDlg;
34 
35  dwStyle = (DWORD)SendMessageW(hStartupListCtrl, LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0);
36  dwStyle = dwStyle | LVS_EX_FULLROWSELECT | LVS_EX_CHECKBOXES;
37  SendMessageW(hStartupListCtrl, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, dwStyle);
38 
40 
41  // Initialize the application page's controls
42  column.mask = LVCF_TEXT | LVCF_WIDTH;
43 
45  column.pszText = szTemp;
46  column.cx = 150;
47  (void)ListView_InsertColumn(hStartupListCtrl, 0, &column);
48 
49  column.mask = LVCF_TEXT | LVCF_WIDTH;
51  column.pszText = szTemp;
52  column.cx = 150;
53  (void)ListView_InsertColumn(hStartupListCtrl, 1, &column);
54 
55  column.mask = LVCF_TEXT | LVCF_WIDTH;
57  column.pszText = szTemp;
58  column.cx = 250;
59  (void)ListView_InsertColumn(hStartupListCtrl, 2, &column);
60 
61  GetAutostartEntriesFromRegistry(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run"));
62  GetAutostartEntriesFromRegistry(HKEY_CURRENT_USER, _T("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run"));
63  GetDisabledAutostartEntriesFromRegistry (_T("SOFTWARE\\Microsoft\\Shared Tools\\MSConfig\\startupreg"));
64  GetDisabledAutostartEntriesFromRegistry (_T("SOFTWARE\\Microsoft\\Shared Tools\\MSConfig\\startupfolder"));
65 
66  //FIXME: What about HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\Userinit
67  //FIXME: Common Startup (startmenu)
68 
69  return TRUE;
70  }
71 
72  return 0;
73 }
74 
75 
76  void
78 {
79  HKEY hKey, hSubKey;
80  DWORD Index, SubIndex, dwValues, dwSubValues;
81  DWORD dwValueLength, dwDataLength = MAX_VALUE_NAME;
82  LV_ITEM item;
83  TCHAR* Data;
84  TCHAR szValueName[MAX_KEY_LENGTH];
85  TCHAR szSubValueName[MAX_KEY_LENGTH];
86  TCHAR szSubPath[MAX_KEY_LENGTH];
87 
89  {
90  if (RegQueryInfoKey(hKey, NULL, NULL, NULL, &dwValues, NULL, NULL, NULL, NULL, NULL, NULL, NULL) == ERROR_SUCCESS)
91  {
92  for (Index = 0; Index < dwValues; Index++)
93  {
94  dwValueLength = MAX_KEY_LENGTH;
95  dwDataLength = MAX_VALUE_NAME;
96  Data = HeapAlloc(GetProcessHeap(), 0, MAX_VALUE_NAME * sizeof(TCHAR));
97  if (Data == NULL)
98  break;
99 
100  if(RegEnumKeyEx(hKey, Index, szValueName, &dwValueLength, NULL, NULL, NULL, NULL) != ERROR_SUCCESS)
101  {
102  HeapFree(GetProcessHeap(), 0, Data);
103  continue;
104  }
105  _stprintf(szSubPath, _T("%s\\%s"), szBasePath, szValueName);
106  memset(&item, 0, sizeof(LV_ITEM));
107  item.mask = LVIF_TEXT;
108  item.iImage = 0;
109  item.pszText = szValueName;
110  item.iItem = ListView_GetItemCount(hStartupListCtrl);
111  item.lParam = 0;
112  (void)ListView_InsertItem(hStartupListCtrl, &item);
114  {
115  if (RegQueryInfoKey(hSubKey, NULL, NULL, NULL, NULL, NULL, NULL, &dwSubValues, NULL, NULL, NULL, NULL) == ERROR_SUCCESS)
116  {
117  for(SubIndex = 0; SubIndex < dwSubValues; SubIndex++)
118  {
119  dwValueLength = MAX_KEY_LENGTH;
120  dwDataLength = MAX_VALUE_NAME;
121  if(RegEnumValue(hSubKey, SubIndex, szSubValueName, &dwValueLength, NULL, NULL, (LPBYTE)Data, &dwDataLength) == ERROR_SUCCESS)
122  {
123  item.iSubItem = -1;
124  if (!_tcscmp(szSubValueName, _T("command")))
125  item.iSubItem = 1;
126  else if (!_tcscmp(szSubValueName, _T("key")) || !_tcscmp(szSubValueName, _T("location")))
127  item.iSubItem = 2;
128  else if (!_tcscmp(szSubValueName, _T("item")))
129  item.iSubItem = 0;
130  if (item.iSubItem != -1)
131  {
132  GetLongPathName(Data, Data, (DWORD) _tcsclen(Data));
133  item.pszText = Data;
134  SendMessageW(hStartupListCtrl, LVM_SETITEMTEXT, item.iItem, (LPARAM) &item);
135  }
136  }
137  }
138  }
139  }
140  RegCloseKey(hSubKey);
141  HeapFree(GetProcessHeap(), 0, Data);
142  }
143  }
144  RegCloseKey(hKey);
145  }
146 }
147 
148 void
150 {
151  HKEY hKey;
152  DWORD Index, dwValues, retVal, dwType;
153  DWORD dwValueLength, dwDataLength = MAX_VALUE_NAME;
154  TCHAR* Data;
155  TCHAR lpValueName[MAX_KEY_LENGTH];
157  LV_ITEM item;
158 
159  if (RegOpenKeyEx(hRootKey, KeyName, 0, KEY_READ, &hKey) == ERROR_SUCCESS)
160  {
161  if (RegQueryInfoKey(hKey, NULL, NULL, NULL, NULL, NULL, NULL, &dwValues, NULL, NULL, NULL, NULL) == ERROR_SUCCESS)
162  {
163  for (Index = 0, retVal = ERROR_SUCCESS; Index < dwValues; Index++)
164  {
165  dwValueLength = MAX_KEY_LENGTH;
166  dwDataLength = MAX_VALUE_NAME;
167  Data = HeapAlloc(GetProcessHeap(), 0, MAX_VALUE_NAME * sizeof(TCHAR));
168  if (Data == NULL)
169  break;
170  retVal = RegEnumValue(hKey, Index, lpValueName, &dwValueLength, NULL, &dwType, (LPBYTE)Data, &dwDataLength);
171  if (retVal == ERROR_SUCCESS)
172  {
173  memset(&item, 0, sizeof(LV_ITEM));
174  item.mask = LVIF_TEXT;
175  item.iImage = 0;
176  item.pszText = lpValueName;
177  item.iItem = ListView_GetItemCount(hStartupListCtrl);
178  item.lParam = 0;
179  (void)ListView_InsertItem(hStartupListCtrl, &item);
180  ListView_SetCheckState(hStartupListCtrl, item.iItem, TRUE);
181 
182  if ((dwType == REG_SZ) || (dwType == REG_EXPAND_SZ))
183  {
184  GetLongPathName(Data, Data, (DWORD) _tcsclen(Data));
185  item.pszText = Data;
186  item.iSubItem = 1;
187  SendMessageW(hStartupListCtrl, LVM_SETITEMTEXT, item.iItem, (LPARAM) &item);
188  }
189 
190  switch (PtrToLong(hRootKey))
191  {
193  _tcscpy(Path, _T("HKLM\\\0"));
194  break;
196  _tcscpy(Path, _T("HKCU\\\0"));
197  break;
198  default:
199  _tcscpy(Path, _T("\0"));
200  }
201 
202  _tcscat(Path, KeyName);
203  item.pszText = Path;
204  item.iSubItem = 2;
205  SendMessageW(hStartupListCtrl, LVM_SETITEMTEXT, item.iItem, (LPARAM) &item);
206  }
207  HeapFree(GetProcessHeap(), 0, Data);
208  }
209  }
210  RegCloseKey(hKey);
211  }
212 
213 }
void GetAutostartEntriesFromRegistry(HKEY hRootKey, TCHAR *KeyName)
Definition: startuppage.c:149
void GetDisabledAutostartEntriesFromRegistry(TCHAR *szBasePath)
Definition: startuppage.c:77
#define LV_ITEM
Definition: commctrl.h:2307
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING KeyName
Definition: ndis.h:4693
Definition: tftpd.h:59
#define TRUE
Definition: types.h:120
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:47
#define LVCF_WIDTH
Definition: commctrl.h:2557
#define RegQueryInfoKey
Definition: winreg.h:521
#define ERROR_SUCCESS
Definition: deptool.c:10
#define LVCF_TEXT
Definition: commctrl.h:2558
#define KEY_READ
Definition: nt_native.h:1023
int _tcscmp(const _TCHAR *s1, const _TCHAR *s2)
Definition: tcscmp.h:8
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
#define DWORD
Definition: msvc.h:34
#define IDS_STARTUP_COLUMN_PATH
Definition: resource.h:87
#define HKEY_CURRENT_USER
Definition: winreg.h:11
#define LV_COLUMN
Definition: commctrl.h:2517
#define PtrToLong(p)
Definition: basetsd.h:84
#define CALLBACK
Definition: compat.h:27
#define LVS_EX_FULLROWSELECT
Definition: commctrl.h:2704
_TCHAR * _tcscpy(_TCHAR *to, const _TCHAR *from)
Definition: tcscpy.h:8
#define ListView_InsertItem(hwnd, pitem)
Definition: commctrl.h:2378
#define SWP_NOZORDER
Definition: winuser.h:1232
int32_t INT_PTR
Definition: typedefs.h:62
WPARAM wParam
Definition: combotst.c:138
HWND hStartupDialog
Definition: startuppage.c:14
#define LVM_SETITEMTEXT
Definition: commctrl.h:2659
UINT_PTR WPARAM
Definition: windef.h:207
uint32_t ULONG_PTR
Definition: typedefs.h:63
#define LVIF_TEXT
Definition: commctrl.h:2279
#define MAX_KEY_LENGTH
#define ListView_InsertColumn(hwnd, iCol, pcol)
Definition: commctrl.h:2606
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:52
LONG_PTR LPARAM
Definition: windef.h:208
smooth NULL
Definition: ftsmooth.c:416
#define MAX_VALUE_NAME
Definition: control.c:23
_In_ LPGUID _In_ PVOID Data
Definition: classpnp.h:778
#define ListView_GetItemCount(hwnd)
Definition: commctrl.h:2277
char TCHAR
Definition: xmlstorage.h:189
#define _T(x)
Definition: vfdio.h:22
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
if(!(yy_init))
Definition: macro.lex.yy.c:717
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define SWP_NOACTIVATE
Definition: winuser.h:1227
unsigned int UINT
Definition: ndis.h:50
static const UCHAR Index[8]
Definition: usbohci.c:18
unsigned long DWORD
Definition: ntddk_ex.h:95
#define LVM_SETEXTENDEDLISTVIEWSTYLE
Definition: commctrl.h:2694
#define LVS_EX_CHECKBOXES
Definition: commctrl.h:2701
#define RegEnumKeyEx
Definition: winreg.h:510
#define LVM_GETEXTENDEDLISTVIEWSTYLE
Definition: commctrl.h:2697
#define SWP_NOSIZE
Definition: winuser.h:1230
#define _stprintf
Definition: utility.h:124
#define RegOpenKeyEx
Definition: winreg.h:520
HINSTANCE hInst
Definition: dxdiag.c:13
PRTL_UNICODE_STRING_BUFFER Path
static ATOM item
Definition: dde.c:856
#define REG_EXPAND_SZ
Definition: nt_native.h:1494
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define _tcsclen
Definition: tchar.h:1447
#define ListView_SetCheckState(hwndLV, i, fCheck)
Definition: commctrl.h:2644
#define IDC_STARTUP_LIST
Definition: resource.h:19
_TCHAR * _tcscat(_TCHAR *s, const _TCHAR *append)
Definition: tcscat.h:8
HWND hStartupPage
Definition: startuppage.c:12
#define IDS_STARTUP_COLUMN_CMD
Definition: resource.h:86
INT_PTR CALLBACK StartupPageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
Definition: startuppage.c:20
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
LONG RegEnumValue(HKEY Key, ULONG Index, PWCHAR ValueName, ULONG *NameSize, ULONG *Type, PUCHAR Data, ULONG *DataSize)
GLenum GLenum GLvoid GLvoid * column
Definition: glext.h:5664
#define IDS_STARTUP_COLUMN_ELEMENT
Definition: resource.h:85
#define memset(x, y, z)
Definition: compat.h:39
#define WM_INITDIALOG
Definition: winuser.h:1715
LPARAM lParam
Definition: combotst.c:139
#define HeapFree(x, y, z)
Definition: compat.h:394
#define LoadString
Definition: winuser.h:5685
HWND hStartupListCtrl
Definition: startuppage.c:13
#define SWP_NOOWNERZORDER
Definition: winuser.h:1234
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define KEY_ENUMERATE_SUB_KEYS
Definition: nt_native.h:1019
#define REG_SZ
Definition: layer.c:22