Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygencontrol.cGo to the documentation of this file.00001 /* 00002 * PROJECT: ReactOS System Control Panel 00003 * FILE: base/applications/control/control.c 00004 * PURPOSE: ReactOS System Control Panel 00005 * PROGRAMMERS: Gero Kuehn (reactos.filter@gkware.com) 00006 * Colin Finck (mail@colinfinck.de) 00007 */ 00008 00009 #include "control.h" 00010 00011 static const TCHAR szWindowClass[] = _T("DummyControlClass"); 00012 00013 HANDLE hProcessHeap; 00014 HINSTANCE hInst; 00015 00016 static 00017 INT 00018 OpenShellFolder(LPTSTR lpFolderCLSID) 00019 { 00020 TCHAR szParameters[MAX_PATH]; 00021 00022 /* Open a shell folder using "explorer.exe". 00023 The passed CLSID's are all subfolders of the "Control Panel" shell folder. */ 00024 _tcscpy(szParameters, _T("/n,::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\\::{21EC2020-3AEA-1069-A2DD-08002B30309D}")); 00025 _tcscat(szParameters, lpFolderCLSID); 00026 00027 return (INT_PTR)ShellExecute(NULL, 00028 _T("open"), 00029 _T("explorer.exe"), 00030 szParameters, 00031 NULL, 00032 SW_SHOWDEFAULT) > 32; 00033 } 00034 00035 static 00036 INT 00037 RunControlPanel(LPTSTR lpCmd) 00038 { 00039 TCHAR szParameters[MAX_PATH]; 00040 00041 _tcscpy(szParameters, _T("shell32.dll,Control_RunDLL ")); 00042 _tcscat(szParameters, lpCmd); 00043 00044 return RUNDLL(szParameters); 00045 } 00046 00047 int 00048 WINAPI 00049 _tWinMain(HINSTANCE hInstance, 00050 HINSTANCE hPrevInstance, 00051 LPTSTR lpCmdLine, 00052 int nCmdShow) 00053 { 00054 HKEY hKey; 00055 00056 hInst = hInstance; 00057 hProcessHeap = GetProcessHeap(); 00058 00059 /* Show the control panel window if no argument or "panel" was passed */ 00060 if(lpCmdLine[0] == 0 || !_tcsicmp(lpCmdLine, _T("panel"))) 00061 return OpenShellFolder(_T("")); 00062 00063 /* Check one of the built-in control panel handlers */ 00064 if (!_tcsicmp(lpCmdLine, _T("admintools"))) return OpenShellFolder(_T("\\::{D20EA4E1-3957-11d2-A40B-0C5020524153}")); 00065 else if (!_tcsicmp(lpCmdLine, _T("color"))) return RunControlPanel(_T("desk.cpl")); /* TODO: Switch to the "Apperance" tab */ 00066 else if (!_tcsicmp(lpCmdLine, _T("date/time"))) return RunControlPanel(_T("timedate.cpl")); 00067 else if (!_tcsicmp(lpCmdLine, _T("desktop"))) return RunControlPanel(_T("desk.cpl")); 00068 else if (!_tcsicmp(lpCmdLine, _T("folders"))) return RUNDLL(_T("shell32.dll,Options_RunDLL")); 00069 else if (!_tcsicmp(lpCmdLine, _T("fonts"))) return OpenShellFolder(_T("\\::{D20EA4E1-3957-11d2-A40B-0C5020524152}")); 00070 else if (!_tcsicmp(lpCmdLine, _T("infrared"))) return RunControlPanel(_T("irprops.cpl")); 00071 else if (!_tcsicmp(lpCmdLine, _T("international"))) return RunControlPanel(_T("intl.cpl")); 00072 else if (!_tcsicmp(lpCmdLine, _T("keyboard"))) return RunControlPanel(_T("main.cpl @1")); 00073 else if (!_tcsicmp(lpCmdLine, _T("mouse"))) return RunControlPanel(_T("main.cpl @0")); 00074 else if (!_tcsicmp(lpCmdLine, _T("netconnections"))) return OpenShellFolder(_T("\\::{7007ACC7-3202-11D1-AAD2-00805FC1270E}")); 00075 else if (!_tcsicmp(lpCmdLine, _T("netware"))) return RunControlPanel(_T("nwc.cpl")); 00076 else if (!_tcsicmp(lpCmdLine, _T("ports"))) return RunControlPanel(_T("sysdm.cpl")); /* TODO: Switch to the "Computer Name" tab */ 00077 else if (!_tcsicmp(lpCmdLine, _T("printers"))) return OpenShellFolder(_T("\\::{2227A280-3AEA-1069-A2DE-08002B30309D}")); 00078 else if (!_tcsicmp(lpCmdLine, _T("scannercamera"))) return OpenShellFolder(_T("\\::{E211B736-43FD-11D1-9EFB-0000F8757FCD}")); 00079 else if (!_tcsicmp(lpCmdLine, _T("schedtasks"))) return OpenShellFolder(_T("\\::{D6277990-4C6A-11CF-8D87-00AA0060F5BF}")); 00080 else if (!_tcsicmp(lpCmdLine, _T("telephony"))) return RunControlPanel(_T("telephon.cpl")); 00081 else if (!_tcsicmp(lpCmdLine, _T("userpasswords"))) return RunControlPanel(_T("nusrmgr.cpl")); /* Graphical User Account Manager */ 00082 else if (!_tcsicmp(lpCmdLine, _T("userpasswords2"))) return RUNDLL(_T("netplwiz.dll,UsersRunDll")); /* Dialog based advanced User Account Manager */ 00083 00084 /* It is none of them, so look for a handler in the registry */ 00085 if(RegOpenKeyEx(HKEY_LOCAL_MACHINE, 00086 _T("Software\\Microsoft\\Windows\\CurrentVersion\\Control Panel\\Cpls"), 00087 0, 00088 KEY_QUERY_VALUE, 00089 &hKey) == ERROR_SUCCESS) 00090 { 00091 DWORD dwIndex; 00092 00093 for(dwIndex = 0; ; ++dwIndex) 00094 { 00095 DWORD dwDataSize; 00096 DWORD dwValueSize = MAX_VALUE_NAME; 00097 TCHAR szValueName[MAX_VALUE_NAME]; 00098 00099 /* Get the value name and data size */ 00100 if(RegEnumValue(hKey, 00101 dwIndex, 00102 szValueName, 00103 &dwValueSize, 00104 0, 00105 NULL, 00106 NULL, 00107 &dwDataSize) != ERROR_SUCCESS) 00108 break; 00109 00110 /* Check if the parameter is the value name */ 00111 if(!_tcsicmp(lpCmdLine, szValueName)) 00112 { 00113 LPTSTR pszData; 00114 00115 /* Allocate memory for the data plus two more characters, so we can quote the file name if required */ 00116 pszData = (LPTSTR) HeapAlloc(hProcessHeap, 00117 0, 00118 dwDataSize + 2 * sizeof(TCHAR)); 00119 ++pszData; 00120 00121 /* This value is the one we are looking for, so get the data. It is the path to a .cpl file */ 00122 if(RegQueryValueEx(hKey, 00123 szValueName, 00124 0, 00125 NULL, 00126 (LPBYTE)pszData, 00127 &dwDataSize) == ERROR_SUCCESS) 00128 { 00129 INT nReturnValue; 00130 00131 /* Quote the file name if required */ 00132 if(*pszData != '\"') 00133 { 00134 *(--pszData) = '\"'; 00135 pszData[dwDataSize / sizeof(TCHAR)] = '\"'; 00136 pszData[(dwDataSize / sizeof(TCHAR)) + 1] = 0; 00137 } 00138 00139 nReturnValue = RunControlPanel(pszData); 00140 HeapFree(hProcessHeap, 00141 0, 00142 pszData); 00143 RegCloseKey(hKey); 00144 00145 return nReturnValue; 00146 } 00147 00148 HeapFree(hProcessHeap, 00149 0, 00150 pszData); 00151 } 00152 } 00153 00154 RegCloseKey(hKey); 00155 } 00156 00157 /* It's none of the known parameters, so interpret the parameter as the file name of a control panel applet */ 00158 return RunControlPanel(lpCmdLine); 00159 } Generated on Thu Feb 9 04:39:04 2012 for ReactOS by
1.6.3
|