[KSPROXY]
[reactos.git] / reactos / dll / cpl / sysdm / hardware.c
index 349afdc..4b919bb 100644 (file)
 /*
- *  ReactOS
- *  Copyright (C) 2004 ReactOS Team
+ * PROJECT:     ReactOS System Control Panel Applet
+ * LICENSE:     GPL - See COPYING in the top level directory
+ * FILE:        dll/cpl/sysdm/hardware.c
+ * PURPOSE:     Hardware devices
+ * COPYRIGHT:   Copyright Thomas Weidenmueller <w3seek@reactos.org>
+ *              Copyright 2006 Ged Murphy <gedmurphy@gmail.com>
  *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-/* $Id$
- *
- * PROJECT:         ReactOS System Control Panel
- * FILE:            lib/cpl/system/hardware.c
- * PURPOSE:         Hardware devices
- * PROGRAMMER:      Thomas Weidenmueller (w3seek@users.sourceforge.net)
- * UPDATE HISTORY:
- *      03-04-2004  Created
  */
-#include <windows.h>
-#include <stdlib.h>
-#include <tchar.h>
 
-#include "resource.h"
-#include "sysdm.h"
+#include "precomp.h"
+
+typedef BOOL (WINAPI *PDEVMGREXEC)(HWND hWndParent, HINSTANCE hInst, PVOID Unknown, int nCmdShow);
 
-typedef BOOL (STDCALL *PDEVMGREXEC)(HWND hWndParent, HINSTANCE hInst, PVOID Unknown, int nCmdShow);
-BOOL LaunchDeviceManager(HWND hWndParent)
+static BOOL
+LaunchDeviceManager(HWND hWndParent)
 {
-  HMODULE hDll;
-  PDEVMGREXEC DevMgrExec;
-  BOOL Ret;
+/* hack for ROS to start our devmgmt until we have mmc */
+#ifdef __REACTOS__
+    return ((INT_PTR)ShellExecuteW(NULL, L"open", L"devmgmt.exe", NULL, NULL, SW_SHOWNORMAL) > 32);
+#else
+    HMODULE hDll;
+    PDEVMGREXEC DevMgrExec;
+    BOOL Ret;
 
-  hDll = LoadLibrary(_TEXT("devmgr.dll"));
-  if(!hDll)
-    return FALSE;
-  DevMgrExec = (PDEVMGREXEC)GetProcAddress(hDll, "DeviceManager_ExecuteW");
-  if(!DevMgrExec)
-  {
+    hDll = LoadLibrary(_TEXT("devmgr.dll"));
+    if(!hDll)
+        return FALSE;
+
+    DevMgrExec = (PDEVMGREXEC)GetProcAddress(hDll, "DeviceManager_ExecuteW");
+    if(!DevMgrExec)
+    {
+        FreeLibrary(hDll);
+        return FALSE;
+    }
+
+    /* run the Device Manager */
+    Ret = DevMgrExec(hWndParent, hApplet, NULL /* ??? */, SW_SHOW);
     FreeLibrary(hDll);
-    return FALSE;
-  }
-  /* run the Device Manager */
-  Ret = DevMgrExec(hWndParent, hApplet, NULL /* ??? */, SW_SHOW);
-  FreeLibrary(hDll);
-  return Ret;
+    return Ret;
+#endif /* __REACTOS__ */
+}
+
+static VOID
+LaunchHardwareWizard(HWND hWndParent)
+{
+    SHELLEXECUTEINFO shInputDll;
+
+    memset(&shInputDll, 0x0, sizeof(SHELLEXECUTEINFO));
+
+    shInputDll.cbSize = sizeof(shInputDll);
+    shInputDll.hwnd = hWndParent;
+    shInputDll.lpVerb = _T("open");
+    shInputDll.lpFile = _T("rundll32.exe");
+    shInputDll.lpParameters = _T("shell32.dll,Control_RunDLL hdwwiz.cpl");
+
+    if (ShellExecuteEx(&shInputDll) == 0)
+    {
+        MessageBox(NULL,
+                   _T("Can't start hdwwiz.cpl"),
+                   NULL,
+                   MB_OK | MB_ICONERROR);
+    }
 }
 
 /* Property page dialog callback */
 INT_PTR CALLBACK
-HardwarePageProc(
-  HWND hwndDlg,
-  UINT uMsg,
-  WPARAM wParam,
-  LPARAM lParam
-)
+HardwarePageProc(HWND hwndDlg,
+                 UINT uMsg,
+                 WPARAM wParam,
+                 LPARAM lParam)
 {
-  UNREFERENCED_PARAMETER(lParam);
-  switch(uMsg)
-  {
-    case WM_INITDIALOG:
-      break;
-    case WM_COMMAND:
-      switch(LOWORD(wParam))
-      {
-        case IDC_HARDWARE_DEVICE_MANAGER:
-          if(!LaunchDeviceManager(hwndDlg))
-          {
-            /* FIXME */
-          }
-          break;
-      }
-      break;
-  }
-  return FALSE;
-}
+    UNREFERENCED_PARAMETER(lParam);
+
+    switch (uMsg)
+    {
+        case WM_INITDIALOG:
+            break;
 
+        case WM_COMMAND:
+            switch (LOWORD(wParam))
+            {
+                case IDC_HARDWARE_DEVICE_MANAGER:
+                    if (!LaunchDeviceManager(hwndDlg))
+                    {
+                        /* FIXME */
+                    }
+                    return TRUE;
+
+                case IDC_HARDWARE_WIZARD:
+                    LaunchHardwareWizard(hwndDlg);
+                    return TRUE;
+
+                case IDC_HARDWARE_PROFILE:
+                    DialogBox(hApplet,
+                              MAKEINTRESOURCE(IDD_HARDWAREPROFILES),
+                              hwndDlg,
+                              (DLGPROC)HardProfDlgProc);
+                    return TRUE;
+            }
+            break;
+    }
+
+    return FALSE;
+}