2 * PROJECT: ReactOS Applications
3 * LICENSE: LGPL - See COPYING in the top level directory
4 * FILE: base/applications/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
, retVal
;
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, retVal
= ERROR_SUCCESS
; Index
< dwValues
; Index
++)
94 dwValueLength
= MAX_KEY_LENGTH
;
95 dwDataLength
= MAX_VALUE_NAME
;
96 Data
= (TCHAR
*) HeapAlloc(GetProcessHeap(), 0, MAX_VALUE_NAME
* sizeof(TCHAR
));
100 retVal
= RegEnumKeyEx(hKey
, Index
, szValueName
, &dwValueLength
, NULL
, NULL
, NULL
, NULL
);
101 _stprintf(szSubPath
, _T("%s\\%s"), szBasePath
, szValueName
);
102 memset(&item
, 0, sizeof(LV_ITEM
));
103 item
.mask
= LVIF_TEXT
;
105 item
.pszText
= szValueName
;
106 item
.iItem
= ListView_GetItemCount(hStartupListCtrl
);
108 (void)ListView_InsertItem(hStartupListCtrl
, &item
);
109 if(RegOpenKeyEx(HKEY_LOCAL_MACHINE
, szSubPath
, 0, KEY_READ
| KEY_ENUMERATE_SUB_KEYS
, &hSubKey
) == ERROR_SUCCESS
)
111 if (RegQueryInfoKey(hSubKey
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, &dwSubValues
, NULL
, NULL
, NULL
, NULL
) == ERROR_SUCCESS
)
113 for(SubIndex
= 0; SubIndex
< dwSubValues
; SubIndex
++)
115 dwValueLength
= MAX_KEY_LENGTH
;
116 dwDataLength
= MAX_VALUE_NAME
;
117 if(RegEnumValue(hSubKey
, SubIndex
, szSubValueName
, &dwValueLength
, NULL
, NULL
, (LPBYTE
)Data
, &dwDataLength
) == ERROR_SUCCESS
)
120 if (!_tcscmp(szSubValueName
, _T("command")))
122 else if (!_tcscmp(szSubValueName
, _T("key")) || !_tcscmp(szSubValueName
, _T("location")))
124 else if (!_tcscmp(szSubValueName
, _T("item")))
126 if (item
.iSubItem
!= -1)
128 GetLongPathName(Data
, Data
, (DWORD
) _tcsclen(Data
));
130 SendMessage(hStartupListCtrl
, LVM_SETITEMTEXT
, item
.iItem
, (LPARAM
) &item
);
136 RegCloseKey(hSubKey
);
137 HeapFree(GetProcessHeap(), 0, Data
);
145 GetAutostartEntriesFromRegistry ( HKEY hRootKey
, TCHAR
* KeyName
)
148 DWORD Index
, dwValues
, retVal
, dwType
;
149 DWORD dwValueLength
, dwDataLength
= MAX_VALUE_NAME
;
151 TCHAR lpValueName
[MAX_KEY_LENGTH
];
152 TCHAR Path
[MAX_KEY_LENGTH
+ 5];
155 if (RegOpenKeyEx(hRootKey
, KeyName
, 0, KEY_READ
, &hKey
) == ERROR_SUCCESS
)
157 if (RegQueryInfoKey(hKey
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, &dwValues
, NULL
, NULL
, NULL
, NULL
) == ERROR_SUCCESS
)
159 for (Index
= 0, retVal
= ERROR_SUCCESS
; Index
< dwValues
; Index
++)
161 dwValueLength
= MAX_KEY_LENGTH
;
162 dwDataLength
= MAX_VALUE_NAME
;
163 Data
= (TCHAR
*) HeapAlloc(GetProcessHeap(), 0, MAX_VALUE_NAME
* sizeof(TCHAR
));
166 retVal
= RegEnumValue(hKey
, Index
, lpValueName
, &dwValueLength
, NULL
, &dwType
, (LPBYTE
)Data
, &dwDataLength
);
167 if (retVal
== ERROR_SUCCESS
)
169 memset(&item
, 0, sizeof(LV_ITEM
));
170 item
.mask
= LVIF_TEXT
;
172 item
.pszText
= lpValueName
;
173 item
.iItem
= ListView_GetItemCount(hStartupListCtrl
);
175 (void)ListView_InsertItem(hStartupListCtrl
, &item
);
176 ListView_SetCheckState(hStartupListCtrl
, item
.iItem
, TRUE
);
178 if ((dwType
== REG_SZ
) || (dwType
== REG_EXPAND_SZ
))
180 GetLongPathName(Data
, Data
, (DWORD
) _tcsclen(Data
));
183 SendMessage(hStartupListCtrl
, LVM_SETITEMTEXT
, item
.iItem
, (LPARAM
) &item
);
186 switch (PtrToLong(hRootKey
))
188 case PtrToLong(HKEY_LOCAL_MACHINE
):
189 _tcscpy(Path
, _T("HKLM\\\0"));
191 case PtrToLong(HKEY_CURRENT_USER
):
192 _tcscpy(Path
, _T("HKCU\\\0"));
195 _tcscpy(Path
, _T("\0"));
198 _tcscat(Path
, KeyName
);
201 SendMessage(hStartupListCtrl
, LVM_SETITEMTEXT
, item
.iItem
, (LPARAM
) &item
);
202 HeapFree(GetProcessHeap(), 0, Data
);