xref: /reactos/dll/cpl/sysdm/hardware.c (revision 1734f297)
1 /*
2  * PROJECT:     ReactOS System Control Panel Applet
3  * LICENSE:     GPL - See COPYING in the top level directory
4  * FILE:        dll/cpl/sysdm/hardware.c
5  * PURPOSE:     Hardware devices
6  * COPYRIGHT:   Copyright Thomas Weidenmueller <w3seek@reactos.org>
7  *              Copyright 2006 Ged Murphy <gedmurphy@gmail.com>
8  *
9  */
10 
11 #include "precomp.h"
12 
13 typedef BOOL (WINAPI *PDEVMGREXEC)(HWND hWndParent, HINSTANCE hInst, PVOID Unknown, int nCmdShow);
14 
15 static BOOL
16 LaunchDeviceManager(HWND hWndParent)
17 {
18 /* Hack for ROS to start our devmgmt until we have MMC */
19 #ifdef __REACTOS__
20     return ((INT_PTR)ShellExecuteW(NULL, L"open", L"devmgmt.exe", NULL, NULL, SW_SHOWNORMAL) > 32);
21 #else
22     HMODULE hDll;
23     PDEVMGREXEC DevMgrExec;
24     BOOL Ret;
25 
26     hDll = LoadLibrary(_TEXT("devmgr.dll"));
27     if(!hDll)
28         return FALSE;
29 
30     DevMgrExec = (PDEVMGREXEC)GetProcAddress(hDll, "DeviceManager_ExecuteW");
31     if(!DevMgrExec)
32     {
33         FreeLibrary(hDll);
34         return FALSE;
35     }
36 
37     /* Run the Device Manager */
38     Ret = DevMgrExec(hWndParent, hApplet, NULL /* ??? */, SW_SHOW);
39     FreeLibrary(hDll);
40     return Ret;
41 #endif /* __REACTOS__ */
42 }
43 
44 static VOID
45 LaunchHardwareWizard(HWND hWndParent)
46 {
47     SHELLEXECUTEINFO shInputDll;
48 
49     memset(&shInputDll, 0x0, sizeof(SHELLEXECUTEINFO));
50 
51     shInputDll.cbSize = sizeof(shInputDll);
52     shInputDll.hwnd = hWndParent;
53     shInputDll.lpVerb = _T("open");
54     shInputDll.lpFile = _T("rundll32.exe");
55     shInputDll.lpParameters = _T("shell32.dll,Control_RunDLL hdwwiz.cpl");
56 
57     if (ShellExecuteEx(&shInputDll) == 0)
58     {
59         MessageBox(NULL,
60                    _T("Can't start hdwwiz.cpl"),
61                    NULL,
62                    MB_OK | MB_ICONERROR);
63     }
64 }
65 
66 /* Property page dialog callback */
67 INT_PTR CALLBACK
68 HardwarePageProc(HWND hwndDlg,
69                  UINT uMsg,
70                  WPARAM wParam,
71                  LPARAM lParam)
72 {
73     UNREFERENCED_PARAMETER(lParam);
74 
75     switch (uMsg)
76     {
77         case WM_INITDIALOG:
78             break;
79 
80         case WM_COMMAND:
81             switch (LOWORD(wParam))
82             {
83                 case IDC_HARDWARE_DEVICE_MANAGER:
84                     if (!LaunchDeviceManager(hwndDlg))
85                     {
86                         /* FIXME */
87                     }
88                     return TRUE;
89 
90                 case IDC_HARDWARE_WIZARD:
91                     LaunchHardwareWizard(hwndDlg);
92                     return TRUE;
93 
94                 case IDC_HARDWARE_PROFILE:
95                     DialogBox(hApplet,
96                               MAKEINTRESOURCE(IDD_HARDWAREPROFILES),
97                               hwndDlg,
98                               HardProfDlgProc);
99                     return TRUE;
100             }
101             break;
102     }
103 
104     return FALSE;
105 }
106