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");
18 OpenShellFolder(LPTSTR lpFolderCLSID
)
20 TCHAR szParameters
[MAX_PATH
];
22 /* Open a shell folder using "explorer.exe".
23 The passed CLSID's are all subfolders of the "Control Panel" shell folder. */
24 _tcscpy(szParameters
, _T("/n,::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\\::{21EC2020-3AEA-1069-A2DD-08002B30309D}"));
25 _tcscat(szParameters
, lpFolderCLSID
);
27 return (INT_PTR
)ShellExecute(NULL
,
37 RunControlPanel(LPTSTR lpCmd
)
39 TCHAR szParameters
[MAX_PATH
];
41 _tcscpy(szParameters
, _T("shell32.dll,Control_RunDLL "));
42 _tcscat(szParameters
, lpCmd
);
44 return RUNDLL(szParameters
);
49 _tWinMain(HINSTANCE hInstance
,
50 HINSTANCE hPrevInstance
,
57 hProcessHeap
= GetProcessHeap();
59 /* Show the control panel window if no argument or "panel" was passed */
60 if(lpCmdLine
[0] == 0 || !_tcsicmp(lpCmdLine
, _T("panel")))
61 return OpenShellFolder(_T(""));
63 /* Check one of the built-in control panel handlers */
64 if (!_tcsicmp(lpCmdLine
, _T("admintools"))) return OpenShellFolder(_T("\\::{D20EA4E1-3957-11d2-A40B-0C5020524153}"));
65 else if (!_tcsicmp(lpCmdLine
, _T("color"))) return RunControlPanel(_T("desk.cpl")); /* TODO: Switch to the "Apperance" tab */
66 else if (!_tcsicmp(lpCmdLine
, _T("date/time"))) return RunControlPanel(_T("timedate.cpl"));
67 else if (!_tcsicmp(lpCmdLine
, _T("desktop"))) return RunControlPanel(_T("desk.cpl"));
68 else if (!_tcsicmp(lpCmdLine
, _T("folders"))) return RUNDLL(_T("shell32.dll,Options_RunDLL"));
69 else if (!_tcsicmp(lpCmdLine
, _T("fonts"))) return OpenShellFolder(_T("\\::{D20EA4E1-3957-11d2-A40B-0C5020524152}"));
70 else if (!_tcsicmp(lpCmdLine
, _T("infrared"))) return RunControlPanel(_T("irprops.cpl"));
71 else if (!_tcsicmp(lpCmdLine
, _T("international"))) return RunControlPanel(_T("intl.cpl"));
72 else if (!_tcsicmp(lpCmdLine
, _T("keyboard"))) return RunControlPanel(_T("main.cpl @1"));
73 else if (!_tcsicmp(lpCmdLine
, _T("mouse"))) return RunControlPanel(_T("main.cpl @0"));
74 else if (!_tcsicmp(lpCmdLine
, _T("netconnections"))) return OpenShellFolder(_T("\\::{7007ACC7-3202-11D1-AAD2-00805FC1270E}"));
75 else if (!_tcsicmp(lpCmdLine
, _T("netware"))) return RunControlPanel(_T("nwc.cpl"));
76 else if (!_tcsicmp(lpCmdLine
, _T("ports"))) return RunControlPanel(_T("sysdm.cpl")); /* TODO: Switch to the "Computer Name" tab */
77 else if (!_tcsicmp(lpCmdLine
, _T("printers"))) return OpenShellFolder(_T("\\::{2227A280-3AEA-1069-A2DE-08002B30309D}"));
78 else if (!_tcsicmp(lpCmdLine
, _T("scannercamera"))) return OpenShellFolder(_T("\\::{E211B736-43FD-11D1-9EFB-0000F8757FCD}"));
79 else if (!_tcsicmp(lpCmdLine
, _T("schedtasks"))) return OpenShellFolder(_T("\\::{D6277990-4C6A-11CF-8D87-00AA0060F5BF}"));
80 else if (!_tcsicmp(lpCmdLine
, _T("telephony"))) return RunControlPanel(_T("telephon.cpl"));
81 else if (!_tcsicmp(lpCmdLine
, _T("userpasswords"))) return RunControlPanel(_T("nusrmgr.cpl")); /* Graphical User Account Manager */
82 else if (!_tcsicmp(lpCmdLine
, _T("userpasswords2"))) return RUNDLL(_T("netplwiz.dll,UsersRunDll")); /* Dialog based advanced User Account Manager */
84 /* It is none of them, so look for a handler in the registry */
85 if(RegOpenKeyEx(HKEY_LOCAL_MACHINE
,
86 _T("Software\\Microsoft\\Windows\\CurrentVersion\\Control Panel\\Cpls"),
89 &hKey
) == ERROR_SUCCESS
)
93 for(dwIndex
= 0; ; ++dwIndex
)
96 DWORD dwValueSize
= MAX_VALUE_NAME
;
97 TCHAR szValueName
[MAX_VALUE_NAME
];
99 /* Get the value name and data size */
100 if(RegEnumValue(hKey
,
107 &dwDataSize
) != ERROR_SUCCESS
)
110 /* Check if the parameter is the value name */
111 if(!_tcsicmp(lpCmdLine
, szValueName
))
115 /* Allocate memory for the data plus two more characters, so we can quote the file name if required */
116 pszData
= (LPTSTR
) HeapAlloc(hProcessHeap
,
118 dwDataSize
+ 2 * sizeof(TCHAR
));
121 /* This value is the one we are looking for, so get the data. It is the path to a .cpl file */
122 if(RegQueryValueEx(hKey
,
127 &dwDataSize
) == ERROR_SUCCESS
)
131 /* Quote the file name if required */
135 pszData
[dwDataSize
/ sizeof(TCHAR
)] = '\"';
136 pszData
[(dwDataSize
/ sizeof(TCHAR
)) + 1] = 0;
139 nReturnValue
= RunControlPanel(pszData
);
140 HeapFree(hProcessHeap
,
148 HeapFree(hProcessHeap
,
157 /* It's none of the known parameters, so interpret the parameter as the file name of a control panel applet */
158 return RunControlPanel(lpCmdLine
);