set eol-style:native
[reactos.git] / reactos / subsys / system / msconfig / startuppage.c
index 0de04f1..87c109b 100644 (file)
-#include <precomp.h>\r
-\r
-HWND hStartupPage;\r
-HWND hStartupListCtrl;\r
-HWND hStartupDialog;\r
-\r
-void GetAutostartEntriesFromRegistry ( HKEY hRootKey, TCHAR* KeyName );\r
-\r
-INT_PTR CALLBACK\r
-StartupPageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)\r
-{\r
-    LV_COLUMN   column;\r
-    TCHAR       szTemp[256];\r
-    DWORD dwStyle;\r
-\r
-    switch (message) {\r
-    case WM_INITDIALOG:\r
-\r
-        hStartupListCtrl = GetDlgItem(hDlg, IDC_STARTUP_LIST);\r
-        hStartupDialog = hDlg;\r
-\r
-        dwStyle = SendMessage(hStartupListCtrl, LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0);\r
-        dwStyle = dwStyle | LVS_EX_FULLROWSELECT | LVS_EX_CHECKBOXES;\r
-        SendMessage(hStartupListCtrl, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, dwStyle);\r
-\r
-        SetWindowPos(hDlg, NULL, 10, 32, 0, 0, SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOSIZE | SWP_NOZORDER);\r
-\r
-        // Initialize the application page's controls\r
-        column.mask = LVCF_TEXT | LVCF_WIDTH;\r
-\r
-        LoadString(hInst, IDS_STARTUP_COLUMN_ELEMENT, szTemp, 256);\r
-        column.pszText = szTemp;\r
-        column.cx = 150;\r
-        ListView_InsertColumn(hStartupListCtrl, 0, &column);\r
-\r
-        column.mask = LVCF_TEXT | LVCF_WIDTH;\r
-        LoadString(hInst, IDS_STARTUP_COLUMN_CMD, szTemp, 256);\r
-        column.pszText = szTemp;\r
-        column.cx = 150;\r
-        ListView_InsertColumn(hStartupListCtrl, 1, &column);\r
-\r
-        column.mask = LVCF_TEXT | LVCF_WIDTH;\r
-        LoadString(hInst, IDS_STARTUP_COLUMN_PATH, szTemp, 256);\r
-        column.pszText = szTemp;\r
-        column.cx = 250;\r
-        ListView_InsertColumn(hStartupListCtrl, 2, &column);\r
-\r
-        GetAutostartEntriesFromRegistry(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run"));\r
-        GetAutostartEntriesFromRegistry(HKEY_CURRENT_USER, _T("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run"));\r
-        //FIXME: What about HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\Userinit\r
-        //FIXME: Common Startup (startmenu)\r
-\r
-        return TRUE;\r
-    }\r
-\r
-    return 0;\r
-}\r
-\r
-void\r
-GetAutostartEntriesFromRegistry ( HKEY hRootKey, TCHAR* KeyName )\r
-{\r
-    HKEY hKey;\r
-    DWORD Index, dwValues, retVal, dwType;\r
-    DWORD dwValueLength, dwDataLength = MAX_VALUE_NAME; \r
-    TCHAR Data[MAX_VALUE_NAME];\r
-    TCHAR lpValueName[MAX_KEY_LENGTH];\r
-    TCHAR Path[MAX_KEY_LENGTH + 5];\r
-    LV_ITEM item;\r
-\r
-    if (RegOpenKeyEx(hRootKey, KeyName, 0, KEY_READ, &hKey) == ERROR_SUCCESS)\r
-    {\r
-        if (RegQueryInfoKey(hKey, NULL, NULL, NULL, NULL, NULL, NULL, &dwValues, NULL, NULL, NULL, NULL) == ERROR_SUCCESS)\r
-        {\r
-            for (Index = 0, retVal = ERROR_SUCCESS; Index < dwValues; Index++) \r
-            {\r
-                dwValueLength = MAX_VALUE_NAME;\r
-                dwDataLength = MAX_VALUE_NAME;\r
-                retVal = RegEnumValue(hKey, Index, lpValueName, &dwValueLength, NULL, &dwType, (LPBYTE)Data, &dwDataLength);\r
-                if (retVal == ERROR_SUCCESS) \r
-                {\r
-                    memset(&item, 0, sizeof(LV_ITEM));\r
-                    item.mask = LVIF_TEXT;\r
-                    item.iImage = 0;\r
-                    item.pszText = lpValueName;\r
-                    item.iItem = ListView_GetItemCount(hStartupListCtrl);\r
-                    item.lParam = 0;\r
-                    ListView_InsertItem(hStartupListCtrl, &item);\r
-\r
-                    if (dwType == REG_SZ)\r
-                    {\r
-                        GetLongPathName(Data, Data, sizeof(Data));\r
-                        item.pszText = Data;\r
-                        item.iSubItem = 1;\r
-                        SendMessage(hStartupListCtrl, LVM_SETITEMTEXT, item.iItem, (LPARAM) &item);\r
-                    }\r
-                    \r
-                    if (hRootKey == HKEY_LOCAL_MACHINE)\r
-                        _tcscpy(Path, _T("HKLM\\"));\r
-                    if (hRootKey == HKEY_CURRENT_USER)\r
-                        _tcscpy(Path, _T("HKCU\\"));\r
-\r
-                    _tcscat(Path, KeyName);\r
-                    item.pszText = Path;\r
-                    item.iSubItem = 2;\r
-                    SendMessage(hStartupListCtrl, LVM_SETITEMTEXT, item.iItem, (LPARAM) &item);\r
-                }\r
-            }\r
-        }\r
-        RegCloseKey(hKey);\r
-    }\r
-\r
-}\r
+#include <precomp.h>
+
+HWND hStartupPage;
+HWND hStartupListCtrl;
+HWND hStartupDialog;
+
+void GetAutostartEntriesFromRegistry ( HKEY hRootKey, TCHAR* KeyName );
+
+INT_PTR CALLBACK
+StartupPageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
+{
+    LV_COLUMN   column;
+    TCHAR       szTemp[256];
+    DWORD dwStyle;
+
+    switch (message) {
+    case WM_INITDIALOG:
+
+        hStartupListCtrl = GetDlgItem(hDlg, IDC_STARTUP_LIST);
+        hStartupDialog = hDlg;
+
+        dwStyle = SendMessage(hStartupListCtrl, LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0);
+        dwStyle = dwStyle | LVS_EX_FULLROWSELECT | LVS_EX_CHECKBOXES;
+        SendMessage(hStartupListCtrl, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, dwStyle);
+
+        SetWindowPos(hDlg, NULL, 10, 32, 0, 0, SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOSIZE | SWP_NOZORDER);
+
+        // Initialize the application page's controls
+        column.mask = LVCF_TEXT | LVCF_WIDTH;
+
+        LoadString(hInst, IDS_STARTUP_COLUMN_ELEMENT, szTemp, 256);
+        column.pszText = szTemp;
+        column.cx = 150;
+        ListView_InsertColumn(hStartupListCtrl, 0, &column);
+
+        column.mask = LVCF_TEXT | LVCF_WIDTH;
+        LoadString(hInst, IDS_STARTUP_COLUMN_CMD, szTemp, 256);
+        column.pszText = szTemp;
+        column.cx = 150;
+        ListView_InsertColumn(hStartupListCtrl, 1, &column);
+
+        column.mask = LVCF_TEXT | LVCF_WIDTH;
+        LoadString(hInst, IDS_STARTUP_COLUMN_PATH, szTemp, 256);
+        column.pszText = szTemp;
+        column.cx = 250;
+        ListView_InsertColumn(hStartupListCtrl, 2, &column);
+
+        GetAutostartEntriesFromRegistry(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run"));
+        GetAutostartEntriesFromRegistry(HKEY_CURRENT_USER, _T("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run"));
+        //FIXME: What about HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\Userinit
+        //FIXME: Common Startup (startmenu)
+
+        return TRUE;
+    }
+
+    return 0;
+}
+
+void
+GetAutostartEntriesFromRegistry ( HKEY hRootKey, TCHAR* KeyName )
+{
+    HKEY hKey;
+    DWORD Index, dwValues, retVal, dwType;
+    DWORD dwValueLength, dwDataLength = MAX_VALUE_NAME; 
+    TCHAR Data[MAX_VALUE_NAME];
+    TCHAR lpValueName[MAX_KEY_LENGTH];
+    TCHAR Path[MAX_KEY_LENGTH + 5];
+    LV_ITEM item;
+
+    if (RegOpenKeyEx(hRootKey, KeyName, 0, KEY_READ, &hKey) == ERROR_SUCCESS)
+    {
+        if (RegQueryInfoKey(hKey, NULL, NULL, NULL, NULL, NULL, NULL, &dwValues, NULL, NULL, NULL, NULL) == ERROR_SUCCESS)
+        {
+            for (Index = 0, retVal = ERROR_SUCCESS; Index < dwValues; Index++) 
+            {
+                dwValueLength = MAX_VALUE_NAME;
+                dwDataLength = MAX_VALUE_NAME;
+                retVal = RegEnumValue(hKey, Index, lpValueName, &dwValueLength, NULL, &dwType, (LPBYTE)Data, &dwDataLength);
+                if (retVal == ERROR_SUCCESS) 
+                {
+                    memset(&item, 0, sizeof(LV_ITEM));
+                    item.mask = LVIF_TEXT;
+                    item.iImage = 0;
+                    item.pszText = lpValueName;
+                    item.iItem = ListView_GetItemCount(hStartupListCtrl);
+                    item.lParam = 0;
+                    ListView_InsertItem(hStartupListCtrl, &item);
+
+                    if (dwType == REG_SZ)
+                    {
+                        GetLongPathName(Data, Data, sizeof(Data));
+                        item.pszText = Data;
+                        item.iSubItem = 1;
+                        SendMessage(hStartupListCtrl, LVM_SETITEMTEXT, item.iItem, (LPARAM) &item);
+                    }
+                    
+                    if (hRootKey == HKEY_LOCAL_MACHINE)
+                        _tcscpy(Path, _T("HKLM\\"));
+                    if (hRootKey == HKEY_CURRENT_USER)
+                        _tcscpy(Path, _T("HKCU\\"));
+
+                    _tcscat(Path, KeyName);
+                    item.pszText = Path;
+                    item.iSubItem = 2;
+                    SendMessage(hStartupListCtrl, LVM_SETITEMTEXT, item.iItem, (LPARAM) &item);
+                }
+            }
+        }
+        RegCloseKey(hKey);
+    }
+
+}