ReactOS  0.4.12-dev-14-gd0c8636
startuppage.c File Reference
#include "precomp.h"
Include dependency graph for startuppage.c:

Go to the source code of this file.

Functions

void GetAutostartEntriesFromRegistry (HKEY hRootKey, TCHAR *KeyName)
 
void GetDisabledAutostartEntriesFromRegistry (TCHAR *szBasePath)
 
INT_PTR CALLBACK StartupPageWndProc (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
 

Variables

HWND hStartupPage
 
HWND hStartupListCtrl
 
HWND hStartupDialog
 

Function Documentation

◆ GetAutostartEntriesFromRegistry()

void GetAutostartEntriesFromRegistry ( HKEY  hRootKey,
TCHAR KeyName 
)

Definition at line 149 of file startuppage.c.

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;
178  item.lParam = 0;
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 }
#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
#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 RegQueryInfoKey
Definition: winreg.h:521
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_READ
Definition: nt_native.h:1023
#define HKEY_CURRENT_USER
Definition: winreg.h:11
#define PtrToLong(p)
Definition: basetsd.h:84
_TCHAR * _tcscpy(_TCHAR *to, const _TCHAR *from)
Definition: tcscpy.h:8
#define ListView_InsertItem(hwnd, pitem)
Definition: commctrl.h:2378
#define LVM_SETITEMTEXT
Definition: commctrl.h:2659
uint32_t ULONG_PTR
Definition: typedefs.h:63
#define LVIF_TEXT
Definition: commctrl.h:2279
#define MAX_KEY_LENGTH
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)
static const UCHAR Index[8]
Definition: usbohci.c:18
unsigned long DWORD
Definition: ntddk_ex.h:95
#define RegOpenKeyEx
Definition: winreg.h:520
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
_TCHAR * _tcscat(_TCHAR *s, const _TCHAR *append)
Definition: tcscat.h:8
LONG RegEnumValue(HKEY Key, ULONG Index, PWCHAR ValueName, ULONG *NameSize, ULONG *Type, PUCHAR Data, ULONG *DataSize)
#define memset(x, y, z)
Definition: compat.h:39
#define HeapFree(x, y, z)
Definition: compat.h:394
HWND hStartupListCtrl
Definition: startuppage.c:13
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define REG_SZ
Definition: layer.c:22

◆ GetDisabledAutostartEntriesFromRegistry()

void GetDisabledAutostartEntriesFromRegistry ( TCHAR szBasePath)

Definition at line 77 of file startuppage.c.

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;
111  item.lParam = 0;
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 }
#define LV_ITEM
Definition: commctrl.h:2307
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:47
#define RegQueryInfoKey
Definition: winreg.h:521
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_READ
Definition: nt_native.h:1023
int _tcscmp(const _TCHAR *s1, const _TCHAR *s2)
Definition: tcscmp.h:8
#define ListView_InsertItem(hwnd, pitem)
Definition: commctrl.h:2378
#define LVM_SETITEMTEXT
Definition: commctrl.h:2659
#define LVIF_TEXT
Definition: commctrl.h:2279
#define MAX_KEY_LENGTH
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
static const UCHAR Index[8]
Definition: usbohci.c:18
unsigned long DWORD
Definition: ntddk_ex.h:95
#define RegEnumKeyEx
Definition: winreg.h:510
#define _stprintf
Definition: utility.h:124
#define RegOpenKeyEx
Definition: winreg.h:520
static ATOM item
Definition: dde.c:856
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define _tcsclen
Definition: tchar.h:1447
LONG RegEnumValue(HKEY Key, ULONG Index, PWCHAR ValueName, ULONG *NameSize, ULONG *Type, PUCHAR Data, ULONG *DataSize)
#define memset(x, y, z)
Definition: compat.h:39
#define HeapFree(x, y, z)
Definition: compat.h:394
HWND hStartupListCtrl
Definition: startuppage.c:13
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define KEY_ENUMERATE_SUB_KEYS
Definition: nt_native.h:1019

◆ StartupPageWndProc()

INT_PTR CALLBACK StartupPageWndProc ( HWND  hDlg,
UINT  message,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 20 of file startuppage.c.

21 {
23  TCHAR szTemp[256];
24  DWORD dwStyle;
25 
28 
29  switch (message) {
30  case WM_INITDIALOG:
31 
33  hStartupDialog = hDlg;
34 
36  dwStyle = dwStyle | LVS_EX_FULLROWSELECT | LVS_EX_CHECKBOXES;
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;
48 
49  column.mask = LVCF_TEXT | LVCF_WIDTH;
51  column.pszText = szTemp;
52  column.cx = 150;
54 
55  column.mask = LVCF_TEXT | LVCF_WIDTH;
57  column.pszText = szTemp;
58  column.cx = 250;
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 }
void GetAutostartEntriesFromRegistry(HKEY hRootKey, TCHAR *KeyName)
Definition: startuppage.c:149
void GetDisabledAutostartEntriesFromRegistry(TCHAR *szBasePath)
Definition: startuppage.c:77
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 LVCF_TEXT
Definition: commctrl.h:2558
#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 LVS_EX_FULLROWSELECT
Definition: commctrl.h:2704
#define SWP_NOZORDER
Definition: winuser.h:1232
WPARAM wParam
Definition: combotst.c:138
HWND hStartupDialog
Definition: startuppage.c:14
#define ListView_InsertColumn(hwnd, iCol, pcol)
Definition: commctrl.h:2606
smooth NULL
Definition: ftsmooth.c:416
char TCHAR
Definition: xmlstorage.h:189
#define _T(x)
Definition: vfdio.h:22
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define SWP_NOACTIVATE
Definition: winuser.h:1227
unsigned long DWORD
Definition: ntddk_ex.h:95
#define LVM_SETEXTENDEDLISTVIEWSTYLE
Definition: commctrl.h:2694
#define LVS_EX_CHECKBOXES
Definition: commctrl.h:2701
#define LVM_GETEXTENDEDLISTVIEWSTYLE
Definition: commctrl.h:2697
#define SWP_NOSIZE
Definition: winuser.h:1230
HINSTANCE hInst
Definition: dxdiag.c:13
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define IDC_STARTUP_LIST
Definition: resource.h:19
#define IDS_STARTUP_COLUMN_CMD
Definition: resource.h:86
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
GLenum GLenum GLvoid GLvoid * column
Definition: glext.h:5664
#define IDS_STARTUP_COLUMN_ELEMENT
Definition: resource.h:85
#define WM_INITDIALOG
Definition: winuser.h:1715
LPARAM lParam
Definition: combotst.c:139
#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

Variable Documentation

◆ hStartupDialog

HWND hStartupDialog

Definition at line 14 of file startuppage.c.

◆ hStartupListCtrl

HWND hStartupListCtrl

Definition at line 13 of file startuppage.c.

◆ hStartupPage

HWND hStartupPage

Definition at line 12 of file startuppage.c.