2 * PROJECT: ReactOS System Control Panel
3 * FILE: base/applications/control/control.c
4 * PURPOSE: ReactOS System Control Panel
5 * PROGRAMMERS: Gero Kuehn (reactos.filter@gkware.com)
6 * Colin Finck (mail@colinfinck.de)
11 static const TCHAR szWindowClass
[] = _T("DummyControlClass");
17 OpenShellFolder(LPTSTR lpFolderCLSID
)
19 TCHAR szParameters
[MAX_PATH
];
21 /* Open a shell folder using "explorer.exe".
22 The passed CLSID's are all subfolders of the "Control Panel" shell folder. */
23 _tcscpy(szParameters
, _T("/n,::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\\::{21EC2020-3AEA-1069-A2DD-08002B30309D}"));
24 _tcscat(szParameters
, lpFolderCLSID
);
26 return (INT
)(INT_PTR
)ShellExecute(NULL
, _T("open"), _T("explorer.exe"), szParameters
, NULL
, SW_SHOWDEFAULT
) > 32;
30 RunControlPanel(LPTSTR lpCmd
)
32 TCHAR szParameters
[MAX_PATH
];
34 _tcscpy(szParameters
, _T("shell32.dll,Control_RunDLL "));
35 _tcscat(szParameters
, lpCmd
);
37 return RUNDLL(szParameters
);
41 _tWinMain(HINSTANCE hInstance
, HINSTANCE hPrevInstance
, LPTSTR lpCmdLine
, int nCmdShow
)
46 hProcessHeap
= GetProcessHeap();
48 /* Show the control panel window if no argument or "panel" was passed */
49 if(lpCmdLine
[0] == 0 || !_tcsicmp(lpCmdLine
, _T("panel")))
50 return OpenShellFolder(_T(""));
52 /* Check one of the built-in control panel handlers */
53 if (!_tcsicmp(lpCmdLine
, _T("admintools"))) return OpenShellFolder(_T("\\::{D20EA4E1-3957-11d2-A40B-0C5020524153}"));
54 else if (!_tcsicmp(lpCmdLine
, _T("color"))) return RunControlPanel(_T("desk.cpl")); /* TODO: Switch to the "Apperance" tab */
55 else if (!_tcsicmp(lpCmdLine
, _T("date/time"))) return RunControlPanel(_T("timedate.cpl"));
56 else if (!_tcsicmp(lpCmdLine
, _T("desktop"))) return RunControlPanel(_T("desk.cpl"));
57 else if (!_tcsicmp(lpCmdLine
, _T("folders"))) return RUNDLL(_T("shell32.dll,Options_RunDLL"));
58 else if (!_tcsicmp(lpCmdLine
, _T("fonts"))) return OpenShellFolder(_T("\\::{D20EA4E1-3957-11d2-A40B-0C5020524152}"));
59 else if (!_tcsicmp(lpCmdLine
, _T("infrared"))) return RunControlPanel(_T("irprops.cpl"));
60 else if (!_tcsicmp(lpCmdLine
, _T("international"))) return RunControlPanel(_T("intl.cpl"));
61 else if (!_tcsicmp(lpCmdLine
, _T("keyboard"))) return RunControlPanel(_T("main.cpl @1"));
62 else if (!_tcsicmp(lpCmdLine
, _T("mouse"))) return RunControlPanel(_T("main.cpl @0"));
63 else if (!_tcsicmp(lpCmdLine
, _T("netconnections"))) return OpenShellFolder(_T("\\::{7007ACC7-3202-11D1-AAD2-00805FC1270E}"));
64 else if (!_tcsicmp(lpCmdLine
, _T("netware"))) return RunControlPanel(_T("nwc.cpl"));
65 else if (!_tcsicmp(lpCmdLine
, _T("ports"))) return RunControlPanel(_T("sysdm.cpl")); /* TODO: Switch to the "Computer Name" tab */
66 else if (!_tcsicmp(lpCmdLine
, _T("printers"))) return OpenShellFolder(_T("\\::{2227A280-3AEA-1069-A2DE-08002B30309D}"));
67 else if (!_tcsicmp(lpCmdLine
, _T("scannercamera"))) return OpenShellFolder(_T("\\::{E211B736-43FD-11D1-9EFB-0000F8757FCD}"));
68 else if (!_tcsicmp(lpCmdLine
, _T("schedtasks"))) return OpenShellFolder(_T("\\::{D6277990-4C6A-11CF-8D87-00AA0060F5BF}"));
69 else if (!_tcsicmp(lpCmdLine
, _T("telephony"))) return RunControlPanel(_T("telephon.cpl"));
70 else if (!_tcsicmp(lpCmdLine
, _T("userpasswords"))) return RunControlPanel(_T("nusrmgr.cpl")); /* Graphical User Account Manager */
71 else if (!_tcsicmp(lpCmdLine
, _T("userpasswords2"))) return RUNDLL(_T("netplwiz.dll,UsersRunDll")); /* Dialog based advanced User Account Manager */
73 /* It is none of them, so look for a handler in the registry */
74 if(RegOpenKeyEx(HKEY_LOCAL_MACHINE
, _T("Software\\Microsoft\\Windows\\CurrentVersion\\Control Panel\\Cpls"), 0, KEY_QUERY_VALUE
, &hKey
) == ERROR_SUCCESS
)
78 for(dwIndex
= 0; ; ++dwIndex
)
81 DWORD dwValueSize
= MAX_VALUE_NAME
;
82 TCHAR szValueName
[MAX_VALUE_NAME
];
84 /* Get the value name and data size */
85 if(RegEnumValue(hKey
, dwIndex
, szValueName
, &dwValueSize
, 0, NULL
, NULL
, &dwDataSize
) != ERROR_SUCCESS
)
88 /* Check if the parameter is the value name */
89 if(!_tcsicmp(lpCmdLine
, szValueName
))
93 /* Allocate memory for the data plus two more characters, so we can quote the file name if required */
94 pszData
= (LPTSTR
) HeapAlloc(hProcessHeap
, 0, dwDataSize
+ 2 * sizeof(TCHAR
));
97 /* This value is the one we are looking for, so get the data. It is the path to a .cpl file */
98 if(RegQueryValueEx(hKey
, szValueName
, 0, NULL
, (LPBYTE
)pszData
, &dwDataSize
) == ERROR_SUCCESS
)
102 /* Quote the file name if required */
106 pszData
[dwDataSize
/ sizeof(TCHAR
)] = '\"';
107 pszData
[(dwDataSize
/ sizeof(TCHAR
)) + 1] = 0;
110 nReturnValue
= RunControlPanel(pszData
);
111 HeapFree(hProcessHeap
, 0, pszData
);
117 HeapFree(hProcessHeap
, 0, pszData
);
124 /* It's none of the known parameters, so interpret the parameter as the file name of a control panel applet */
125 return RunControlPanel(lpCmdLine
);