Use w32api.
authorEric Kohl <eric.kohl@reactos.org>
Wed, 30 Jun 2004 12:11:11 +0000 (12:11 +0000)
committerEric Kohl <eric.kohl@reactos.org>
Wed, 30 Jun 2004 12:11:11 +0000 (12:11 +0000)
svn path=/trunk/; revision=9944

reactos/lib/cpl/appwiz/Makefile
reactos/lib/cpl/appwiz/appwiz.c
reactos/lib/cpl/appwiz/appwiz.rc
reactos/lib/cpl/control/Makefile
reactos/lib/cpl/control/control.c

index dead14f..28d6a09 100644 (file)
@@ -1,4 +1,4 @@
-# $Id: Makefile,v 1.1 2004/06/18 20:43:44 kuehng Exp $
+# $Id: Makefile,v 1.2 2004/06/30 12:11:11 ekohl Exp $
 
 PATH_TO_TOP = ../../..
 
@@ -13,16 +13,22 @@ TARGET_INSTALLDIR = system32
 TARGET_BASE = $(TARGET_BASE_LIB_CPL_SYSDM)
 
 TARGET_CFLAGS = \
+ -D_WIN32_IE=0x0600 \
+ -D_WIN32_WINNT=0x0501 \
  -I./include \
  -DUNICODE \
  -D_UNICODE \
  -D__REACTOS__ \
+ -D__USE_W32API \
  -Wall \
  -Werror \
  -fno-builtin
 
 TARGET_LFLAGS = -nostartfiles
 
+
+TARGET_LFLAGS = -nostartfiles
+
 TARGET_SDKLIBS = kernel32.a user32.a comctl32.a
 
 TARGET_GCCLIBS = gcc
index 72ccb83..c33f6c3 100644 (file)
@@ -16,7 +16,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-/* $Id: appwiz.c,v 1.1 2004/06/18 20:43:44 kuehng Exp $
+/* $Id: appwiz.c,v 1.2 2004/06/30 12:11:11 ekohl Exp $
  *
  * PROJECT:         ReactOS Software Control Panel
  * FILE:            lib/cpl/system/appwiz.c
  *      06-17-2004  Created
  */
 
-#include <stdlib.h>
-#include <stdio.h>
-#include <stdarg.h>
-#include <tchar.h>
 #include <windows.h>
-
-#ifdef _MSC_VER
 #include <commctrl.h>
 #include <cpl.h>
-#endif
 
 #include <stdlib.h>
+#include <stdio.h>
+#include <stdarg.h>
 #include <tchar.h>
 #include <process.h>
-#include <stdio.h>
 
 #include "resource.h"
 #include "appwiz.h"
@@ -55,124 +49,162 @@ HINSTANCE hApplet = 0;
 /* Applets */
 APPLET Applets[NUM_APPLETS] = 
 {
-       {IDI_CPLSYSTEM, IDS_CPLSYSTEMNAME, IDS_CPLSYSTEMDESCRIPTION, SystemApplet}
+  {IDI_CPLSYSTEM, IDS_CPLSYSTEMNAME, IDS_CPLSYSTEMDESCRIPTION, SystemApplet}
 };
 
-void CallUninstall(HWND hwndDlg)
+
+static VOID
+CallUninstall(HWND hwndDlg)
 {
-       int nIndex;
-       nIndex = SendDlgItemMessage(hwndDlg,IDC_SOFTWARELIST,LB_GETCURSEL,0,0);
-       if(nIndex == -1)
-               MessageBox(hwndDlg,L"No item selected",L"Error",MB_ICONSTOP);
-       else {
-               HKEY hKey;
-               DWORD dwType = REG_SZ;
-               TCHAR pszUninstallString[MAX_PATH];
-               DWORD dwSize = MAX_PATH;
-               hKey = (HKEY)SendDlgItemMessage(hwndDlg,IDC_SOFTWARELIST,LB_GETITEMDATA,(WPARAM)nIndex,0);
-               if(RegQueryValueEx(hKey,L"UninstallString",NULL,&dwType,(BYTE*)pszUninstallString,&dwSize)==ERROR_SUCCESS)
-               {
-                       STARTUPINFO si;
-                       PROCESS_INFORMATION pi;
-                       memset(&si,0x00,sizeof(si));
-                       si.cb = sizeof(si);
-                       si.wShowWindow = SW_SHOW;
-                       if(CreateProcess(NULL,pszUninstallString,NULL,NULL,FALSE,0,NULL,NULL,&si,&pi))
-                       {
-                               CloseHandle(pi.hProcess);
-                               CloseHandle(pi.hThread);
-                       }
-               } else {
-                       MessageBox(hwndDlg,L"Unable to read UninstallString. This entry is invalid or has been created by an MSI installer.",L"Error",MB_ICONSTOP);
-               }
-       }
+  STARTUPINFO si;
+  PROCESS_INFORMATION pi;
+  int nIndex;
+  HKEY hKey;
+  DWORD dwType;
+  TCHAR pszUninstallString[MAX_PATH];
+  DWORD dwSize;
+
+  nIndex = SendDlgItemMessage(hwndDlg, IDC_SOFTWARELIST, LB_GETCURSEL, 0, 0);
+  if (nIndex == -1)
+  {
+    MessageBox(hwndDlg,
+               _TEXT("No item selected"),
+               _TEXT("Error"),
+               MB_ICONSTOP);
+  }
+  else
+  {
+    hKey = (HKEY)SendDlgItemMessage(hwndDlg, IDC_SOFTWARELIST, LB_GETITEMDATA, (WPARAM)nIndex, 0);
+
+    dwType = REG_SZ;
+    dwSize = MAX_PATH;
+    if (RegQueryValueEx(hKey,
+                        _TEXT("UninstallString"),
+                        NULL,
+                        &dwType,
+                        (LPBYTE)pszUninstallString,
+                        &dwSize) == ERROR_SUCCESS)
+    {
+      ZeroMemory(&si, sizeof(si));
+      si.cb = sizeof(si);
+      si.wShowWindow = SW_SHOW;
+      if (CreateProcess(NULL,pszUninstallString,NULL,NULL,FALSE,0,NULL,NULL,&si,&pi))
+      {
+        CloseHandle(pi.hProcess);
+        CloseHandle(pi.hThread);
+      }
+    }
+    else
+    {
+      MessageBox(hwndDlg,
+                 _TEXT("Unable to read UninstallString. This entry is invalid or has been created by an MSI installer."),
+                 _TEXT("Error"),
+                 MB_ICONSTOP);
+    }
+  }
 }
 
+
 /* Property page dialog callback */
-BOOL CALLBACK InstallPageProc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam)
+static BOOL CALLBACK
+InstallPageProc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam)
 {
-       switch(uMsg)
-       {
+  TCHAR pszName[MAX_PATH];
+  TCHAR pszDisplayName[MAX_PATH];
+  FILETIME FileTime;
+  HKEY hKey;
+  HKEY hSubKey;
+  DWORD dwType;
+  DWORD dwSize;
+  int i;
+  ULONG index;
+
+  switch (uMsg)
+  {
     case WM_INITDIALOG:
-               {
-                       HKEY hKey;
-                       int i=0;
-                       TCHAR pszName[MAX_PATH];
-                       FILETIME FileTime;
-                       DWORD dwSize = MAX_PATH;
-                       EnableWindow(GetDlgItem(hwndDlg,IDC_INSTALL),FALSE);                    
-                       if(RegOpenKey(HKEY_LOCAL_MACHINE,L"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall",&hKey)!=ERROR_SUCCESS) {
-                               MessageBox(hwndDlg,L"Unable to open Uninstall Key",L"Error",MB_ICONSTOP);
-                               return FALSE;
-                       }
-                       while(RegEnumKeyEx(hKey,i,pszName,&dwSize,NULL,NULL,NULL,&FileTime)==ERROR_SUCCESS)
-                       {
-                               HKEY hSubKey;
-                               if(RegOpenKey(hKey,pszName,&hSubKey)==ERROR_SUCCESS)
-                               {
-                                       DWORD dwType = REG_SZ;
-                                       TCHAR pszDisplayName[MAX_PATH];
-                                       DWORD dwSize = MAX_PATH;
-                                       ULONG index;
-                                       if(RegQueryValueEx(hSubKey,L"DisplayName",NULL,&dwType,(BYTE*)pszDisplayName,&dwSize)==ERROR_SUCCESS)
-                                       {
-                                               index = SendDlgItemMessage(hwndDlg,IDC_SOFTWARELIST,LB_ADDSTRING,0,(LPARAM)pszDisplayName);
-                                               SendDlgItemMessage(hwndDlg,IDC_SOFTWARELIST,LB_SETITEMDATA,index,(LPARAM)hSubKey);
-                                       } 
-                               }
-                               
-                               dwSize = MAX_PATH;
-                               i++;
-                       }
-                       RegCloseKey(hKey);
-                       break;
-               }
-               break;
-       case WM_COMMAND:
-               switch(LOWORD(wParam))
-               {
-               case IDC_SOFTWARELIST:
-                       if(HIWORD(wParam)==LBN_DBLCLK)
-                       {
-                               CallUninstall(hwndDlg);
-                       }
-                       break;
-               
-               case IDC_ADDREMOVE:
-                       CallUninstall(hwndDlg);
-                       break;
-               }
-               break;
-       }
-       return FALSE;
+      EnableWindow(GetDlgItem(hwndDlg,IDC_INSTALL), FALSE);
+      if (RegOpenKey(HKEY_LOCAL_MACHINE,
+                     _TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall"),
+                     &hKey) != ERROR_SUCCESS)
+      {
+        MessageBox(hwndDlg,
+                   _TEXT("Unable to open Uninstall Key"),
+                   _TEXT("Error"),
+                   MB_ICONSTOP);
+        return FALSE;
+      }
+
+      i = 0;
+      dwSize = MAX_PATH;
+      while (RegEnumKeyEx (hKey, i, pszName, &dwSize, NULL, NULL, NULL, &FileTime) == ERROR_SUCCESS)
+      {
+        if (RegOpenKey(hKey,pszName,&hSubKey)==ERROR_SUCCESS)
+        {
+          dwType = REG_SZ;
+          dwSize = MAX_PATH;
+          if (RegQueryValueEx(hSubKey,
+                              _TEXT("DisplayName"),
+                              NULL,
+                              &dwType,
+                              (LPBYTE)pszDisplayName,
+                              &dwSize) == ERROR_SUCCESS)
+          {
+            index = SendDlgItemMessage(hwndDlg,IDC_SOFTWARELIST,LB_ADDSTRING,0,(LPARAM)pszDisplayName);
+            SendDlgItemMessage(hwndDlg,IDC_SOFTWARELIST,LB_SETITEMDATA,index,(LPARAM)hSubKey);
+          }
+        }
+
+        dwSize = MAX_PATH;
+        i++;
+      }
+
+      RegCloseKey(hKey);
+      break;
+
+    case WM_COMMAND:
+      switch (LOWORD(wParam))
+      {
+        case IDC_SOFTWARELIST:
+          if (HIWORD(wParam) == LBN_DBLCLK)
+          {
+            CallUninstall(hwndDlg);
+          }
+          break;
+
+        case IDC_ADDREMOVE:
+          CallUninstall(hwndDlg);
+          break;
+      }
+      break;
+  }
+
+  return FALSE;
 }
 
+
 /* Property page dialog callback */
-BOOL CALLBACK RosPageProc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam)
+static BOOL CALLBACK
+RosPageProc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam)
 {
-       switch(uMsg)
-       {
+  switch(uMsg)
+  {
     case WM_INITDIALOG:
-               {
-                       
-                       break;
-               }
-       }
-       return FALSE;
+      break;
+  }
+
+  return FALSE;
 }
 
-static void InitPropSheetPage(PROPSHEETPAGE *psp, WORD idDlg, DLGPROC DlgProc)
+
+static VOID
+InitPropSheetPage(PROPSHEETPAGE *psp, WORD idDlg, DLGPROC DlgProc)
 {
-       ZeroMemory(psp, sizeof(PROPSHEETPAGE));
-       psp->dwSize = sizeof(PROPSHEETPAGE);
-       psp->dwFlags = PSP_DEFAULT;
-       psp->hInstance = hApplet;
-#ifdef _MSC_VER
-       psp->pszTemplate = MAKEINTRESOURCE(idDlg);
-#else
-       psp->u1.pszTemplate = MAKEINTRESOURCE(idDlg);
-#endif
-       psp->pfnDlgProc = DlgProc;
+  ZeroMemory(psp, sizeof(PROPSHEETPAGE));
+  psp->dwSize = sizeof(PROPSHEETPAGE);
+  psp->dwFlags = PSP_DEFAULT;
+  psp->hInstance = hApplet;
+  psp->pszTemplate = MAKEINTRESOURCE(idDlg);
+  psp->pfnDlgProc = DlgProc;
 }
 
 
@@ -181,83 +213,73 @@ static void InitPropSheetPage(PROPSHEETPAGE *psp, WORD idDlg, DLGPROC DlgProc)
 LONG CALLBACK
 SystemApplet(VOID)
 {
-       PROPSHEETPAGE psp[2];
-       PROPSHEETHEADER psh;
-       TCHAR Caption[1024];
-       
-       LoadString(hApplet, IDS_CPLSYSTEMNAME, Caption, sizeof(Caption) / sizeof(TCHAR));
-       
-       ZeroMemory(&psh, sizeof(PROPSHEETHEADER));
-       psh.dwSize = sizeof(PROPSHEETHEADER);
-       psh.dwFlags =  PSH_PROPSHEETPAGE | PSH_PROPTITLE;
-       psh.hwndParent = NULL;
-       psh.hInstance = hApplet;
-#ifdef _MSC_VER
-       psh.hIcon = LoadIcon(hApplet, MAKEINTRESOURCE(IDI_CPLSYSTEM));
-#else
-       psh.u1.hIcon = LoadIcon(hApplet, MAKEINTRESOURCE(IDI_CPLSYSTEM));
-#endif
-       psh.pszCaption = Caption;
-       psh.nPages = sizeof(psp) / sizeof(PROPSHEETHEADER);
-#ifdef _MSC_VER
-       psh.nStartPage = 0;
-       psh.ppsp = psp;
-#else
-       psh.u2.nStartPage = 0;
-       psh.u3.ppsp = psp;
-#endif
-       psh.pfnCallback = NULL;
-       
-
-       InitPropSheetPage(&psp[0], IDD_PROPPAGEINSTALL, InstallPageProc);
-       InitPropSheetPage(&psp[1], IDD_PROPPAGEROSSETUP, RosPageProc);
-       
-       return (LONG)(PropertySheet(&psh) != -1);
+  PROPSHEETPAGE psp[2];
+  PROPSHEETHEADER psh;
+  TCHAR Caption[1024];
+
+  LoadString(hApplet, IDS_CPLSYSTEMNAME, Caption, sizeof(Caption) / sizeof(TCHAR));
+
+  ZeroMemory(&psh, sizeof(PROPSHEETHEADER));
+  psh.dwSize = sizeof(PROPSHEETHEADER);
+  psh.dwFlags =  PSH_PROPSHEETPAGE | PSH_PROPTITLE;
+  psh.hwndParent = NULL;
+  psh.hInstance = hApplet;
+  psh.hIcon = LoadIcon(hApplet, MAKEINTRESOURCE(IDI_CPLSYSTEM));
+  psh.pszCaption = Caption;
+  psh.nPages = sizeof(psp) / sizeof(PROPSHEETHEADER);
+  psh.nStartPage = 0;
+  psh.ppsp = psp;
+  psh.pfnCallback = NULL;
+
+  InitPropSheetPage(&psp[0], IDD_PROPPAGEINSTALL, InstallPageProc);
+  InitPropSheetPage(&psp[1], IDD_PROPPAGEROSSETUP, RosPageProc);
+
+  return (LONG)(PropertySheet(&psh) != -1);
 }
 
+
 /* Control Panel Callback */
-LONG CALLBACK CPlApplet(HWND hwndCPl, UINT uMsg, LPARAM lParam1, LPARAM lParam2)
+LONG CALLBACK
+CPlApplet(HWND hwndCPl, UINT uMsg, LPARAM lParam1, LPARAM lParam2)
 {
-       int i = (int)lParam1;
-       
-       switch(uMsg)
-       {
+  CPLINFO *CPlInfo;
+  DWORD i;
+
+  i = (DWORD)lParam1;
+  switch(uMsg)
+  {
     case CPL_INIT:
-               {
-                       return TRUE;
-               }
+      return TRUE;
+
     case CPL_GETCOUNT:
-               {
-                       return NUM_APPLETS;
-               }
+      return NUM_APPLETS;
+
     case CPL_INQUIRE:
-               {
-                       CPLINFO *CPlInfo = (CPLINFO*)lParam2;
-                       CPlInfo->lData = 0;
-                       CPlInfo->idIcon = Applets[i].idIcon;
-                       CPlInfo->idName = Applets[i].idName;
-                       CPlInfo->idInfo = Applets[i].idDescription;
-                       break;
-               }
+      CPlInfo = (CPLINFO*)lParam2;
+      CPlInfo->lData = 0;
+      CPlInfo->idIcon = Applets[i].idIcon;
+      CPlInfo->idName = Applets[i].idName;
+      CPlInfo->idInfo = Applets[i].idDescription;
+      break;
+
     case CPL_DBLCLK:
-               {
-                       Applets[i].AppletProc();
-                       break;
-               }
-       }
-       return FALSE;
+      Applets[i].AppletProc();
+      break;
+  }
+
+  return FALSE;
 }
 
 
-BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD dwReason, LPVOID lpvReserved)
+BOOL WINAPI
+DllMain(HINSTANCE hinstDLL, DWORD dwReason, LPVOID lpvReserved)
 {
-       switch(dwReason)
-       {
+  switch(dwReason)
+  {
     case DLL_PROCESS_ATTACH:
     case DLL_THREAD_ATTACH:
-               hApplet = hinstDLL;
-               break;
-       }
-       return TRUE;
+      hApplet = hinstDLL;
+      break;
+  }
+  return TRUE;
 }
-
index 4eec9a0..485a020 100644 (file)
@@ -49,7 +49,6 @@ STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_DISABLED | WS_CAPTION
 CAPTION "Install/Uninstall"
 FONT 8, "MS Shell Dlg", 0, 0, 0x0
 BEGIN
-
   ICON            IDI_CPLSYSTEM,-1,PROPSHEETPADDING,18,16,16
   LTEXT "To install a new program, click Install",-1,36,18,PROPSHEETWIDTH-48,8
   PUSHBUTTON "&Install...", IDC_INSTALL, PROPSHEETWIDTH-(72), 36, 60, 14
index 7a70cb4..1ad6360 100644 (file)
@@ -1,4 +1,4 @@
-# $Id: Makefile,v 1.2 2004/06/29 12:03:56 ekohl Exp $
+# $Id: Makefile,v 1.3 2004/06/30 12:10:12 ekohl Exp $
 
 PATH_TO_TOP = ../../..
 
@@ -10,7 +10,16 @@ TARGET_INSTALLDIR = system32
 
 TARGET_APPTYPE = windows
 
-TARGET_CFLAGS = -D_UNICODE -DUNICODE
+TARGET_CFLAGS = \
+ -D_WIN32_IE=0x0600 \
+ -D_WIN32_WINNT=0x0501 \
+ -DUNICODE \
+ -D_UNICODE \
+ -D__REACTOS__ \
+ -D__USE_W32API \
+ -Wall \
+ -Werror \
+ -fno-builtin
 
 TARGET_SDKLIBS = kernel32.a user32.a comctl32.a
 
index 3b35fd6..d10ad03 100644 (file)
@@ -17,7 +17,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-/* $Id: control.c,v 1.3 2004/06/29 12:03:56 ekohl Exp $
+/* $Id: control.c,v 1.4 2004/06/30 12:10:12 ekohl Exp $
  *
  * PROJECT:         ReactOS System Control Panel
  * FILE:            lib/cpl/system/control.c
  * UPDATE HISTORY:
  *      06-13-2004  Created
  */
+#include <windows.h>
+#include <commctrl.h>
+#include <cpl.h>
+
 #include <stdlib.h>
 #include <stdio.h>
 #include <stdarg.h>
 #include <tchar.h>
-#include <windows.h>
-
-#ifdef _MSC_VER
-#include <commctrl.h>
-#include <cpl.h>
-#endif
 
 #include "resource.h"