Author: hbelusca Date: Wed Apr 9 12:29:57 2014 New Revision: 62694
URL: http://svn.reactos.org/svn/reactos?rev=62694&view=rev Log: [CONTROL] - Remove undeeded files. - Fully convert the app to UNICODE. - Code cleanup.
Removed: trunk/reactos/base/applications/control/control.dsp trunk/reactos/base/applications/control/control.dsw trunk/reactos/base/applications/control/control.h Modified: trunk/reactos/base/applications/control/CMakeLists.txt trunk/reactos/base/applications/control/control.c
Modified: trunk/reactos/base/applications/control/CMakeLists.txt URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/control/C... ============================================================================== --- trunk/reactos/base/applications/control/CMakeLists.txt [iso-8859-1] (original) +++ trunk/reactos/base/applications/control/CMakeLists.txt [iso-8859-1] Wed Apr 9 12:29:57 2014 @@ -1,5 +1,5 @@
add_executable(control control.c control.rc) set_module_type(control win32gui UNICODE) -add_importlibs(control advapi32 shell32 msvcrt kernel32) +add_importlibs(control advapi32 shell32 user32 msvcrt kernel32) add_cd_file(TARGET control DESTINATION reactos/system32 FOR all)
Modified: trunk/reactos/base/applications/control/control.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/control/c... ============================================================================== --- trunk/reactos/base/applications/control/control.c [iso-8859-1] (original) +++ trunk/reactos/base/applications/control/control.c [iso-8859-1] Wed Apr 9 12:29:57 2014 @@ -6,154 +6,182 @@ * Colin Finck (mail@colinfinck.de) */
-#include "control.h" +#include <stdio.h>
-static const TCHAR szWindowClass[] = _T("DummyControlClass"); +#define WIN32_NO_STATUS
-HANDLE hProcessHeap; -HINSTANCE hInst; +#include <windef.h> +#include <winbase.h> +#include <winuser.h> +#include <winreg.h> +#include <shellapi.h>
-static -INT -OpenShellFolder(LPTSTR lpFolderCLSID) +#include "resource.h" + +#define MAX_VALUE_NAME 16383 + +/* + * Macro for calling "rundll32.exe" + * According to MSDN, ShellExecute returns a value greater than 32 + * if the operation was successful. + */ +#define RUNDLL(param) \ + ((INT_PTR)ShellExecuteW(NULL, L"open", L"rundll32.exe", (param), NULL, SW_SHOWDEFAULT) > 32) + +VOID +WINAPI +Control_RunDLLW(HWND hWnd, HINSTANCE hInst, LPCWSTR cmd, DWORD nCmdShow); + +static INT +OpenShellFolder(LPWSTR lpFolderCLSID) { - TCHAR szParameters[MAX_PATH]; + WCHAR szParameters[MAX_PATH];
- /* Open a shell folder using "explorer.exe". - The passed CLSID's are all subfolders of the "Control Panel" shell folder. */ - _tcscpy(szParameters, _T("/n,::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\::{21EC2020-3AEA-1069-A2DD-08002B30309D}")); - _tcscat(szParameters, lpFolderCLSID); + /* + * Open a shell folder using "explorer.exe". The passed CLSIDs + * are all subfolders of the "Control Panel" shell folder. + */ + wcscpy(szParameters, L"/n,::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\::{21EC2020-3AEA-1069-A2DD-08002B30309D}"); + wcscat(szParameters, lpFolderCLSID);
- return (INT_PTR)ShellExecute(NULL, - _T("open"), - _T("explorer.exe"), - szParameters, - NULL, - SW_SHOWDEFAULT) > 32; + return (INT_PTR)ShellExecuteW(NULL, + L"open", + L"explorer.exe", + szParameters, + NULL, + SW_SHOWDEFAULT) > 32; }
-static -INT -RunControlPanel(LPTSTR lpCmd) +static INT +RunControlPanel(LPCWSTR lpCmd) { - TCHAR szParameters[MAX_PATH]; + /* + * Old method: + * + WCHAR szParameters[MAX_PATH]; + wcscpy(szParameters, L"shell32.dll,Control_RunDLL "); + wcscat(szParameters, lpCmd); + return RUNDLL(szParameters); + */
- _tcscpy(szParameters, _T("shell32.dll,Control_RunDLL ")); - _tcscat(szParameters, lpCmd); - - return RUNDLL(szParameters); + /* New method: */ + Control_RunDLLW(GetDesktopWindow(), 0, lpCmd, SW_SHOW); + return 1; }
-int +INT WINAPI -_tWinMain(HINSTANCE hInstance, - HINSTANCE hPrevInstance, - LPTSTR lpCmdLine, - int nCmdShow) +wWinMain(HINSTANCE hInstance, + HINSTANCE hPrevInstance, + LPWSTR lpCmdLine, + INT nCmdShow) { HKEY hKey;
- hInst = hInstance; - hProcessHeap = GetProcessHeap(); - /* Show the control panel window if no argument or "panel" was passed */ - if(lpCmdLine[0] == 0 || !_tcsicmp(lpCmdLine, _T("panel"))) - return OpenShellFolder(_T("")); + if (*lpCmdLine == 0 || !_wcsicmp(lpCmdLine, L"panel")) + return OpenShellFolder(L"");
/* Check one of the built-in control panel handlers */ - if (!_tcsicmp(lpCmdLine, _T("admintools"))) return OpenShellFolder(_T("\::{D20EA4E1-3957-11d2-A40B-0C5020524153}")); - else if (!_tcsicmp(lpCmdLine, _T("color"))) return RunControlPanel(_T("desk.cpl")); /* TODO: Switch to the "Apperance" tab */ - else if (!_tcsicmp(lpCmdLine, _T("date/time"))) return RunControlPanel(_T("timedate.cpl")); - else if (!_tcsicmp(lpCmdLine, _T("desktop"))) return RunControlPanel(_T("desk.cpl")); - else if (!_tcsicmp(lpCmdLine, _T("folders"))) return RUNDLL(_T("shell32.dll,Options_RunDLL")); - else if (!_tcsicmp(lpCmdLine, _T("fonts"))) return OpenShellFolder(_T("\::{D20EA4E1-3957-11d2-A40B-0C5020524152}")); - else if (!_tcsicmp(lpCmdLine, _T("infrared"))) return RunControlPanel(_T("irprops.cpl")); - else if (!_tcsicmp(lpCmdLine, _T("international"))) return RunControlPanel(_T("intl.cpl")); - else if (!_tcsicmp(lpCmdLine, _T("keyboard"))) return RunControlPanel(_T("main.cpl @1")); - else if (!_tcsicmp(lpCmdLine, _T("mouse"))) return RunControlPanel(_T("main.cpl @0")); - else if (!_tcsicmp(lpCmdLine, _T("netconnections"))) return OpenShellFolder(_T("\::{7007ACC7-3202-11D1-AAD2-00805FC1270E}")); - else if (!_tcsicmp(lpCmdLine, _T("netware"))) return RunControlPanel(_T("nwc.cpl")); - else if (!_tcsicmp(lpCmdLine, _T("ports"))) return RunControlPanel(_T("sysdm.cpl")); /* TODO: Switch to the "Computer Name" tab */ - else if (!_tcsicmp(lpCmdLine, _T("printers"))) return OpenShellFolder(_T("\::{2227A280-3AEA-1069-A2DE-08002B30309D}")); - else if (!_tcsicmp(lpCmdLine, _T("scannercamera"))) return OpenShellFolder(_T("\::{E211B736-43FD-11D1-9EFB-0000F8757FCD}")); - else if (!_tcsicmp(lpCmdLine, _T("schedtasks"))) return OpenShellFolder(_T("\::{D6277990-4C6A-11CF-8D87-00AA0060F5BF}")); - else if (!_tcsicmp(lpCmdLine, _T("telephony"))) return RunControlPanel(_T("telephon.cpl")); - else if (!_tcsicmp(lpCmdLine, _T("userpasswords"))) return RunControlPanel(_T("nusrmgr.cpl")); /* Graphical User Account Manager */ - else if (!_tcsicmp(lpCmdLine, _T("userpasswords2"))) return RUNDLL(_T("netplwiz.dll,UsersRunDll")); /* Dialog based advanced User Account Manager */ + if (!_wcsicmp(lpCmdLine, L"admintools")) return OpenShellFolder(L"\::{D20EA4E1-3957-11d2-A40B-0C5020524153}"); + else if (!_wcsicmp(lpCmdLine, L"color")) return RunControlPanel(L"desk.cpl"); /* TODO: Switch to the "Apperance" tab */ + else if (!_wcsicmp(lpCmdLine, L"date/time")) return RunControlPanel(L"timedate.cpl"); + else if (!_wcsicmp(lpCmdLine, L"desktop")) return RunControlPanel(L"desk.cpl"); + else if (!_wcsicmp(lpCmdLine, L"folders")) return RUNDLL(L"shell32.dll,Options_RunDLL"); + else if (!_wcsicmp(lpCmdLine, L"fonts")) return OpenShellFolder(L"\::{D20EA4E1-3957-11d2-A40B-0C5020524152}"); + else if (!_wcsicmp(lpCmdLine, L"infrared")) return RunControlPanel(L"irprops.cpl"); + else if (!_wcsicmp(lpCmdLine, L"international")) return RunControlPanel(L"intl.cpl"); + else if (!_wcsicmp(lpCmdLine, L"keyboard")) return RunControlPanel(L"main.cpl @1"); + else if (!_wcsicmp(lpCmdLine, L"mouse")) return RunControlPanel(L"main.cpl @0"); + else if (!_wcsicmp(lpCmdLine, L"netconnections")) return OpenShellFolder(L"\::{7007ACC7-3202-11D1-AAD2-00805FC1270E}"); + else if (!_wcsicmp(lpCmdLine, L"netware")) return RunControlPanel(L"nwc.cpl"); + else if (!_wcsicmp(lpCmdLine, L"ports")) return RunControlPanel(L"sysdm.cpl"); /* TODO: Switch to the "Computer Name" tab */ + else if (!_wcsicmp(lpCmdLine, L"printers")) return OpenShellFolder(L"\::{2227A280-3AEA-1069-A2DE-08002B30309D}"); + else if (!_wcsicmp(lpCmdLine, L"scannercamera")) return OpenShellFolder(L"\::{E211B736-43FD-11D1-9EFB-0000F8757FCD}"); + else if (!_wcsicmp(lpCmdLine, L"schedtasks")) return OpenShellFolder(L"\::{D6277990-4C6A-11CF-8D87-00AA0060F5BF}"); + else if (!_wcsicmp(lpCmdLine, L"telephony")) return RunControlPanel(L"telephon.cpl"); + else if (!_wcsicmp(lpCmdLine, L"userpasswords")) return RunControlPanel(L"nusrmgr.cpl"); /* Graphical User Account Manager */ + else if (!_wcsicmp(lpCmdLine, L"userpasswords2")) return RUNDLL(L"netplwiz.dll,UsersRunDll"); /* Dialog based advanced User Account Manager */
/* It is none of them, so look for a handler in the registry */ - if(RegOpenKeyEx(HKEY_LOCAL_MACHINE, - _T("Software\Microsoft\Windows\CurrentVersion\Control Panel\Cpls"), - 0, - KEY_QUERY_VALUE, - &hKey) == ERROR_SUCCESS) + if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, + L"Software\Microsoft\Windows\CurrentVersion\Control Panel\Cpls", + 0, + KEY_QUERY_VALUE, + &hKey) == ERROR_SUCCESS) { DWORD dwIndex;
- for(dwIndex = 0; ; ++dwIndex) + for (dwIndex = 0; ; ++dwIndex) { DWORD dwDataSize; DWORD dwValueSize = MAX_VALUE_NAME; - TCHAR szValueName[MAX_VALUE_NAME]; + WCHAR szValueName[MAX_VALUE_NAME];
/* Get the value name and data size */ - if(RegEnumValue(hKey, - dwIndex, - szValueName, - &dwValueSize, - 0, - NULL, - NULL, - &dwDataSize) != ERROR_SUCCESS) + if (RegEnumValueW(hKey, + dwIndex, + szValueName, + &dwValueSize, + 0, + NULL, + NULL, + &dwDataSize) != ERROR_SUCCESS) + { break; + }
/* Check if the parameter is the value name */ - if(!_tcsicmp(lpCmdLine, szValueName)) + if (!_wcsicmp(lpCmdLine, szValueName)) { - LPTSTR pszData; - - /* Allocate memory for the data plus two more characters, so we can quote the file name if required */ - pszData = (LPTSTR) HeapAlloc(hProcessHeap, - 0, - dwDataSize + 2 * sizeof(TCHAR)); + /* + * Allocate memory for the data plus two more characters, + * so we can quote the file name if required. + */ + LPWSTR pszData; + pszData = HeapAlloc(GetProcessHeap(), + 0, + dwDataSize + 2 * sizeof(WCHAR)); ++pszData;
- /* This value is the one we are looking for, so get the data. It is the path to a .cpl file */ - if(RegQueryValueEx(hKey, - szValueName, - 0, - NULL, - (LPBYTE)pszData, - &dwDataSize) == ERROR_SUCCESS) + /* + * This value is the one we are looking for, so get the data. + * It is the path to a .cpl file. + */ + if (RegQueryValueExW(hKey, + szValueName, + 0, + NULL, + (LPBYTE)pszData, + &dwDataSize) == ERROR_SUCCESS) { INT nReturnValue;
/* Quote the file name if required */ - if(*pszData != '"') + if (*pszData != L'"') { - *(--pszData) = '"'; - pszData[dwDataSize / sizeof(TCHAR)] = '"'; - pszData[(dwDataSize / sizeof(TCHAR)) + 1] = 0; + *(--pszData) = L'"'; + pszData[dwDataSize / sizeof(WCHAR)] = L'"'; + pszData[(dwDataSize / sizeof(WCHAR)) + 1] = 0; }
nReturnValue = RunControlPanel(pszData); - HeapFree(hProcessHeap, - 0, - pszData); + HeapFree(GetProcessHeap(), 0, pszData); RegCloseKey(hKey);
return nReturnValue; }
- HeapFree(hProcessHeap, - 0, - pszData); + HeapFree(GetProcessHeap(), 0, pszData); } }
RegCloseKey(hKey); }
- /* It's none of the known parameters, so interpret the parameter as the file name of a control panel applet */ + /* + * It's none of the known parameters, so interpret the parameter + * as the file name of a control panel applet. + */ return RunControlPanel(lpCmdLine); }
Removed: trunk/reactos/base/applications/control/control.dsp URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/control/c... ============================================================================== --- trunk/reactos/base/applications/control/control.dsp [iso-8859-1] (original) +++ trunk/reactos/base/applications/control/control.dsp (removed) @@ -1,137 +0,0 @@ -# Microsoft Developer Studio Project File - Name="control" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Application" 0x0101 - -CFG=control - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "control.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "control.mak" CFG="control - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "control - Win32 Release" (based on "Win32 (x86) Application") -!MESSAGE "control - Win32 Debug" (based on "Win32 (x86) Application") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "control - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release" -# PROP Intermediate_Dir "Release" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /W3 /GX /O2 /I "../../../" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0x407 /d "NDEBUG" -# ADD RSC /l 0x407 /d "NDEBUG" /d "MS_COMPILER" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib /nologo /subsystem:windows /machine:I386 -# Begin Custom Build -TargetDir=.\Release -TargetName=control -InputPath=.\Release\control.exe -InputName=control -SOURCE="$(InputPath)" - -"C:\reactos\reactos$(InputName).EXE" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - copy $(TargetDir)$(TargetName).EXE C:\reactos\reactos - -# End Custom Build - -!ELSEIF "$(CFG)" == "control - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Debug" -# PROP Intermediate_Dir "Debug" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c -# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "../../../" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "UNICODE" /D "_UNICODE" /YX /FD /GZ /c -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0x407 /d "_DEBUG" -# ADD RSC /l 0x407 /d "_DEBUG" /d "MS_COMPILER" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept -# Begin Custom Build -TargetDir=.\Debug -TargetName=control -InputPath=.\Debug\control.exe -InputName=control -SOURCE="$(InputPath)" - -"C:\reactos\reactos$(InputName).EXE" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - copy $(TargetDir)$(TargetName).EXE C:\reactos\reactos - -# End Custom Build - -!ENDIF - -# Begin Target - -# Name "control - Win32 Release" -# Name "control - Win32 Debug" -# Begin Group "Source Files" - -# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" -# Begin Source File - -SOURCE=.\control.c -# End Source File -# End Group -# Begin Group "Header Files" - -# PROP Default_Filter "h;hpp;hxx;hm;inl" -# End Group -# Begin Group "Resource Files" - -# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" -# Begin Source File - -SOURCE=.\config.ico -# End Source File -# Begin Source File - -SOURCE=.\control.rc -# End Source File -# End Group -# End Target -# End Project
Removed: trunk/reactos/base/applications/control/control.dsw URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/control/c... ============================================================================== --- trunk/reactos/base/applications/control/control.dsw [iso-8859-1] (original) +++ trunk/reactos/base/applications/control/control.dsw (removed) @@ -1,29 +0,0 @@ -Microsoft Developer Studio Workspace File, Format Version 6.00 -# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! - -############################################################################### - -Project: "control"=.\control.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Global: - -Package=<5> -{{{ -}}} - -Package=<3> -{{{ -}}} - -############################################################################### -
Removed: trunk/reactos/base/applications/control/control.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/control/c... ============================================================================== --- trunk/reactos/base/applications/control/control.h [iso-8859-1] (original) +++ trunk/reactos/base/applications/control/control.h (removed) @@ -1,23 +0,0 @@ -/* - * PROJECT: ReactOS System Control Panel - * FILE: base/applications/control/control.h - * PURPOSE: ReactOS System Control Panel - * PROGRAMMERS: Gero Kuehn (reactos.filter@gkware.com) - * Colin Finck (mail@colinfinck.de) - */ - -#include <tchar.h> -#include <windef.h> -#include <winbase.h> -#include <winuser.h> -#include <winreg.h> -#include <shellapi.h> - -#include "resource.h" - -#define CCH_UINT_MAX 11 -#define MAX_VALUE_NAME 16383 - -/* Macro for calling "rundll32.exe" - According to MSDN, ShellExecute returns a value greater than 32 if the operation was successful. */ -#define RUNDLL(param) ((INT_PTR)ShellExecute(NULL, _T("open"), _T("rundll32.exe"), (param), NULL, SW_SHOWDEFAULT) > 32)