2 * PROJECT: ReactOS Applications
3 * LICENSE: LGPL - See COPYING in the top level directory
4 * FILE: base/applications/msconfig/startuppage.c
5 * PURPOSE: Startup page message handler
6 * COPYRIGHT: Copyright 2005-2006 Christoph von Wittich <Christoph@ApiViewer.de>
13 HWND hStartupListCtrl
;
16 void GetAutostartEntriesFromRegistry ( HKEY hRootKey
, TCHAR
* KeyName
);
17 void GetDisabledAutostartEntriesFromRegistry (TCHAR
* szBasePath
);
20 StartupPageWndProc(HWND hDlg
, UINT message
, WPARAM wParam
, LPARAM lParam
)
26 UNREFERENCED_PARAMETER(lParam
);
27 UNREFERENCED_PARAMETER(wParam
);
32 hStartupListCtrl
= GetDlgItem(hDlg
, IDC_STARTUP_LIST
);
33 hStartupDialog
= hDlg
;
35 dwStyle
= (DWORD
) SendMessage(hStartupListCtrl
, LVM_GETEXTENDEDLISTVIEWSTYLE
, 0, 0);
36 dwStyle
= dwStyle
| LVS_EX_FULLROWSELECT
| LVS_EX_CHECKBOXES
;
37 SendMessage(hStartupListCtrl
, LVM_SETEXTENDEDLISTVIEWSTYLE
, 0, dwStyle
);
39 SetWindowPos(hDlg
, NULL
, 10, 32, 0, 0, SWP_NOACTIVATE
| SWP_NOOWNERZORDER
| SWP_NOSIZE
| SWP_NOZORDER
);
41 // Initialize the application page's controls
42 column
.mask
= LVCF_TEXT
| LVCF_WIDTH
;
44 LoadString(hInst
, IDS_STARTUP_COLUMN_ELEMENT
, szTemp
, 256);
45 column
.pszText
= szTemp
;
47 (void)ListView_InsertColumn(hStartupListCtrl
, 0, &column
);
49 column
.mask
= LVCF_TEXT
| LVCF_WIDTH
;
50 LoadString(hInst
, IDS_STARTUP_COLUMN_CMD
, szTemp
, 256);
51 column
.pszText
= szTemp
;
53 (void)ListView_InsertColumn(hStartupListCtrl
, 1, &column
);
55 column
.mask
= LVCF_TEXT
| LVCF_WIDTH
;
56 LoadString(hInst
, IDS_STARTUP_COLUMN_PATH
, szTemp
, 256);
57 column
.pszText
= szTemp
;
59 (void)ListView_InsertColumn(hStartupListCtrl
, 2, &column
);
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"));
66 //FIXME: What about HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\Userinit
67 //FIXME: Common Startup (startmenu)
77 GetDisabledAutostartEntriesFromRegistry (TCHAR
* szBasePath
)
80 DWORD Index
, SubIndex
, dwValues
, dwSubValues
;
81 DWORD dwValueLength
, dwDataLength
= MAX_VALUE_NAME
;
84 TCHAR szValueName
[MAX_KEY_LENGTH
];
85 TCHAR szSubValueName
[MAX_KEY_LENGTH
];
86 TCHAR szSubPath
[MAX_KEY_LENGTH
];
88 if (RegOpenKeyEx(HKEY_LOCAL_MACHINE
, szBasePath
, 0, KEY_READ
| KEY_ENUMERATE_SUB_KEYS
, &hKey
) == ERROR_SUCCESS
)
90 if (RegQueryInfoKey(hKey
, NULL
, NULL
, NULL
, &dwValues
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
) == ERROR_SUCCESS
)
92 for (Index
= 0; Index
< dwValues
; Index
++)
94 dwValueLength
= MAX_KEY_LENGTH
;
95 dwDataLength
= MAX_VALUE_NAME
;
96 Data
= HeapAlloc(GetProcessHeap(), 0, MAX_VALUE_NAME
* sizeof(TCHAR
));
100 if(RegEnumKeyEx(hKey
, Index
, szValueName
, &dwValueLength
, NULL
, NULL
, NULL
, NULL
) != ERROR_SUCCESS
)
102 HeapFree(GetProcessHeap(), 0, Data
);
105 _stprintf(szSubPath
, _T("%s\\%s"), szBasePath
, szValueName
);
106 memset(&item
, 0, sizeof(LV_ITEM
));
107 item
.mask
= LVIF_TEXT
;
109 item
.pszText
= szValueName
;
110 item
.iItem
= ListView_GetItemCount(hStartupListCtrl
);
112 (void)ListView_InsertItem(hStartupListCtrl
, &item
);
113 if(RegOpenKeyEx(HKEY_LOCAL_MACHINE
, szSubPath
, 0, KEY_READ
| KEY_ENUMERATE_SUB_KEYS
, &hSubKey
) == ERROR_SUCCESS
)
115 if (RegQueryInfoKey(hSubKey
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, &dwSubValues
, NULL
, NULL
, NULL
, NULL
) == ERROR_SUCCESS
)
117 for(SubIndex
= 0; SubIndex
< dwSubValues
; SubIndex
++)
119 dwValueLength
= MAX_KEY_LENGTH
;
120 dwDataLength
= MAX_VALUE_NAME
;
121 if(RegEnumValue(hSubKey
, SubIndex
, szSubValueName
, &dwValueLength
, NULL
, NULL
, (LPBYTE
)Data
, &dwDataLength
) == ERROR_SUCCESS
)
124 if (!_tcscmp(szSubValueName
, _T("command")))
126 else if (!_tcscmp(szSubValueName
, _T("key")) || !_tcscmp(szSubValueName
, _T("location")))
128 else if (!_tcscmp(szSubValueName
, _T("item")))
130 if (item
.iSubItem
!= -1)
132 GetLongPathName(Data
, Data
, (DWORD
) _tcsclen(Data
));
134 SendMessage(hStartupListCtrl
, LVM_SETITEMTEXT
, item
.iItem
, (LPARAM
) &item
);
140 RegCloseKey(hSubKey
);
141 HeapFree(GetProcessHeap(), 0, Data
);
149 GetAutostartEntriesFromRegistry ( HKEY hRootKey
, TCHAR
* KeyName
)
152 DWORD Index
, dwValues
, retVal
, dwType
;
153 DWORD dwValueLength
, dwDataLength
= MAX_VALUE_NAME
;
155 TCHAR lpValueName
[MAX_KEY_LENGTH
];
156 TCHAR Path
[MAX_KEY_LENGTH
+ 5];
159 if (RegOpenKeyEx(hRootKey
, KeyName
, 0, KEY_READ
, &hKey
) == ERROR_SUCCESS
)
161 if (RegQueryInfoKey(hKey
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, &dwValues
, NULL
, NULL
, NULL
, NULL
) == ERROR_SUCCESS
)
163 for (Index
= 0, retVal
= ERROR_SUCCESS
; Index
< dwValues
; Index
++)
165 dwValueLength
= MAX_KEY_LENGTH
;
166 dwDataLength
= MAX_VALUE_NAME
;
167 Data
= HeapAlloc(GetProcessHeap(), 0, MAX_VALUE_NAME
* sizeof(TCHAR
));
170 retVal
= RegEnumValue(hKey
, Index
, lpValueName
, &dwValueLength
, NULL
, &dwType
, (LPBYTE
)Data
, &dwDataLength
);
171 if (retVal
== ERROR_SUCCESS
)
173 memset(&item
, 0, sizeof(LV_ITEM
));
174 item
.mask
= LVIF_TEXT
;
176 item
.pszText
= lpValueName
;
177 item
.iItem
= ListView_GetItemCount(hStartupListCtrl
);
179 (void)ListView_InsertItem(hStartupListCtrl
, &item
);
180 ListView_SetCheckState(hStartupListCtrl
, item
.iItem
, TRUE
);
182 if ((dwType
== REG_SZ
) || (dwType
== REG_EXPAND_SZ
))
184 GetLongPathName(Data
, Data
, (DWORD
) _tcsclen(Data
));
187 SendMessage(hStartupListCtrl
, LVM_SETITEMTEXT
, item
.iItem
, (LPARAM
) &item
);
190 switch (PtrToLong(hRootKey
))
192 case (ULONG_PTR
)HKEY_LOCAL_MACHINE
:
193 _tcscpy(Path
, _T("HKLM\\\0"));
195 case (ULONG_PTR
)HKEY_CURRENT_USER
:
196 _tcscpy(Path
, _T("HKCU\\\0"));
199 _tcscpy(Path
, _T("\0"));
202 _tcscat(Path
, KeyName
);
205 SendMessage(hStartupListCtrl
, LVM_SETITEMTEXT
, item
.iItem
, (LPARAM
) &item
);
207 HeapFree(GetProcessHeap(), 0, Data
);