ReactOS 0.4.15-dev-8127-g6338913
api.cpp File Reference
#include "precomp.h"
#include "devmgmt/MainWindow.h"
#include "properties/properties.h"
Include dependency graph for api.cpp:

Go to the source code of this file.

Classes

class  CDevMgrUIModule
 

Functions

INT_PTR WINAPI DeviceAdvancedPropertiesW (IN HWND hWndParent OPTIONAL, IN LPCWSTR lpMachineName OPTIONAL, IN LPCWSTR lpDeviceID)
 
INT_PTR WINAPI DeviceAdvancedPropertiesA (IN HWND hWndParent OPTIONAL, IN LPCSTR lpMachineName OPTIONAL, IN LPCSTR lpDeviceID)
 
INT_PTR WINAPI DevicePropertiesExA (IN HWND hWndParent OPTIONAL, IN LPCSTR lpMachineName OPTIONAL, IN LPCSTR lpDeviceID OPTIONAL, IN DWORD dwFlags OPTIONAL, IN BOOL bShowDevMgr)
 
INT_PTR WINAPI DevicePropertiesExW (IN HWND hWndParent OPTIONAL, IN LPCWSTR lpMachineName OPTIONAL, IN LPCWSTR lpDeviceID OPTIONAL, IN DWORD dwFlags OPTIONAL, IN BOOL bShowDevMgr)
 
int WINAPI DevicePropertiesA (HWND hWndParent, LPCSTR lpMachineName, LPCSTR lpDeviceID, BOOL bShowDevMgr)
 
int WINAPI DevicePropertiesW (HWND hWndParent, LPCWSTR lpMachineName, LPCWSTR lpDeviceID, BOOL bShowDevMgr)
 
VOID WINAPI DeviceProperties_RunDLLA (HWND hWndParent, HINSTANCE hInst, LPCSTR lpDeviceCmd, int nCmdShow)
 
VOID WINAPI DeviceProperties_RunDLLW (HWND hWndParent, HINSTANCE hInst, LPCWSTR lpDeviceCmd, int nCmdShow)
 
BOOL WINAPI DeviceManager_ExecuteA (HWND hWndParent, HINSTANCE hInst, LPCSTR lpMachineName, int nCmdShow)
 
BOOL WINAPI DeviceManager_ExecuteW (HWND hWndParent, HINSTANCE hInst, LPCWSTR lpMachineName, int nCmdShow)
 
VOID WINAPI DeviceProblemWizard_RunDLLA (HWND hWndParent, HINSTANCE hInst, LPCSTR lpDeviceCmd, int nCmdShow)
 
VOID WINAPI DeviceProblemWizard_RunDLLW (HWND hWndParent, HINSTANCE hInst, LPCWSTR lpDeviceCmd, int nCmdShow)
 
BOOL WINAPI DeviceManagerPrintA (LPCSTR lpMachineName, LPCSTR lpPrinter, int nPrintMode, UINT uNumberOfGuids, LPGUID lpGuids)
 
BOOL WINAPI DeviceManagerPrintW (LPCWSTR lpMachineName, LPCWSTR lpPrinter, int nPrintMode, UINT uNumberOfGuids, LPGUID lpGuids)
 
STDAPI DllCanUnloadNow ()
 
STDAPI DllGetClassObject (REFCLSID rclsid, REFIID riid, LPVOID *ppv)
 
STDAPI DllRegisterServer ()
 
STDAPI DllUnregisterServer ()
 
BOOL WINAPI DllMain (_In_ HINSTANCE hinstDLL, _In_ DWORD dwReason, _In_ LPVOID lpvReserved)
 

Variables

HINSTANCE hDllInstance = NULL
 
CDevMgrUIModule gModule
 

Function Documentation

◆ DeviceAdvancedPropertiesA()

INT_PTR WINAPI DeviceAdvancedPropertiesA ( IN HWND hWndParent  OPTIONAL,
IN LPCSTR lpMachineName  OPTIONAL,
IN LPCSTR  lpDeviceID 
)

Definition at line 118 of file api.cpp.

121{
122 LPWSTR lpMachineNameW = NULL;
123 LPWSTR lpDeviceIDW = NULL;
124 INT_PTR Ret = -1;
125
126 if (lpMachineName != NULL)
127 {
128 if (!(lpMachineNameW = ConvertMultiByteToUnicode(lpMachineName,
129 CP_ACP)))
130 {
131 goto Cleanup;
132 }
133 }
134 if (lpDeviceID != NULL)
135 {
136 if (!(lpDeviceIDW = ConvertMultiByteToUnicode(lpDeviceID,
137 CP_ACP)))
138 {
139 goto Cleanup;
140 }
141 }
142
144 lpMachineNameW,
145 lpDeviceIDW);
146
147Cleanup:
148 if (lpMachineNameW != NULL)
149 {
151 0,
152 lpMachineNameW);
153 }
154 if (lpDeviceIDW != NULL)
155 {
157 0,
158 lpDeviceIDW);
159 }
160
161 return Ret;
162}
#define NULL
Definition: types.h:112
#define GetProcessHeap()
Definition: compat.h:736
#define CP_ACP
Definition: compat.h:109
#define HeapFree(x, y, z)
Definition: compat.h:735
INT_PTR WINAPI DeviceAdvancedPropertiesW(IN HWND hWndParent OPTIONAL, IN LPCWSTR lpMachineName OPTIONAL, IN LPCWSTR lpDeviceID)
Definition: api.cpp:47
LPWSTR ConvertMultiByteToUnicode(IN LPCSTR lpMultiByteStr, IN UINT uCodePage)
Definition: misc.cpp:239
static const WCHAR Cleanup[]
Definition: register.c:80
int32_t INT_PTR
Definition: typedefs.h:64
WCHAR * LPWSTR
Definition: xmlstorage.h:184

◆ DeviceAdvancedPropertiesW()

INT_PTR WINAPI DeviceAdvancedPropertiesW ( IN HWND hWndParent  OPTIONAL,
IN LPCWSTR lpMachineName  OPTIONAL,
IN LPCWSTR  lpDeviceID 
)

Definition at line 47 of file api.cpp.

50{
51 HDEVINFO hDevInfo;
52 SP_DEVINFO_DATA DevInfoData;
53 HINSTANCE hComCtl32;
54 INT_PTR Ret = -1;
55
56 if (lpDeviceID == NULL)
57 {
59 return FALSE;
60 }
61
62 /* dynamically load comctl32 */
63 hComCtl32 = LoadAndInitComctl32();
64 if (hComCtl32 != NULL)
65 {
68 lpMachineName,
69 NULL);
70 if (hDevInfo != INVALID_HANDLE_VALUE)
71 {
72 DevInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
73 if (SetupDiOpenDeviceInfo(hDevInfo,
74 lpDeviceID,
76 0,
77 &DevInfoData))
78 {
80 lpDeviceID,
81 hDevInfo,
82 &DevInfoData,
83 hComCtl32,
84 lpMachineName,
85 0);
86 }
87
89 }
90
91 FreeLibrary(hComCtl32);
92 }
93
94 return Ret;
95}
INT_PTR DisplayDeviceAdvancedProperties(IN HWND hWndParent, IN LPCWSTR lpDeviceID OPTIONAL, IN HDEVINFO DeviceInfoSet, IN PSP_DEVINFO_DATA DeviceInfoData, IN HINSTANCE hComCtl32, IN LPCWSTR lpMachineName, IN DWORD dwFlags)
Definition: advprop.cpp:2940
#define FALSE
Definition: types.h:117
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define SetLastError(x)
Definition: compat.h:752
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define FreeLibrary(x)
Definition: compat.h:748
HINSTANCE LoadAndInitComctl32(VOID)
Definition: misc.cpp:1106
BOOL WINAPI SetupDiDestroyDeviceInfoList(HDEVINFO devinfo)
Definition: devinst.c:2893
#define SetupDiOpenDeviceInfo
Definition: setupapi.h:2614
#define SetupDiCreateDeviceInfoListEx
Definition: setupapi.h:2580
struct _SP_DEVINFO_DATA SP_DEVINFO_DATA

Referenced by DeviceAdvancedPropertiesA().

◆ DeviceManager_ExecuteA()

BOOL WINAPI DeviceManager_ExecuteA ( HWND  hWndParent,
HINSTANCE  hInst,
LPCSTR  lpMachineName,
int  nCmdShow 
)

Definition at line 550 of file api.cpp.

554{
555 LPWSTR lpMachineNameW = NULL;
556 BOOL Ret;
557
558 if (lpMachineName != NULL)
559 {
560 if (!(lpMachineNameW = ConvertMultiByteToUnicode(lpMachineName,
561 CP_ACP)))
562 {
563 return FALSE;
564 }
565 }
566
568 hInst,
569 lpMachineNameW,
570 nCmdShow);
571
572 if (lpMachineNameW != NULL)
573 {
575 0,
576 lpMachineNameW);
577 }
578
579
580 return Ret;
581}
BOOL WINAPI DeviceManager_ExecuteW(HWND hWndParent, HINSTANCE hInst, LPCWSTR lpMachineName, int nCmdShow)
Definition: api.cpp:611
HINSTANCE hInst
Definition: dxdiag.c:13
unsigned int BOOL
Definition: ntddk_ex.h:94

◆ DeviceManager_ExecuteW()

BOOL WINAPI DeviceManager_ExecuteW ( HWND  hWndParent,
HINSTANCE  hInst,
LPCWSTR  lpMachineName,
int  nCmdShow 
)

Definition at line 611 of file api.cpp.

615{
616 // FIXME: Call mmc with devmgmt.msc
617
618 CDeviceManager DevMgr;
619 return DevMgr.Create(hWndParent, hInst, lpMachineName, nCmdShow);
620}
bool Create(_In_ HWND hWndParent, _In_ HINSTANCE hInst, _In_opt_z_ LPCWSTR lpMachineName, _In_ int nCmdShow)
Definition: MainWindow.cpp:95

Referenced by DeviceManager_ExecuteA(), and wWinMain().

◆ DeviceManagerPrintA()

BOOL WINAPI DeviceManagerPrintA ( LPCSTR  lpMachineName,
LPCSTR  lpPrinter,
int  nPrintMode,
UINT  uNumberOfGuids,
LPGUID  lpGuids 
)

Definition at line 732 of file api.cpp.

737{
739 return FALSE;
740}
#define UNIMPLEMENTED
Definition: debug.h:118

◆ DeviceManagerPrintW()

BOOL WINAPI DeviceManagerPrintW ( LPCWSTR  lpMachineName,
LPCWSTR  lpPrinter,
int  nPrintMode,
UINT  uNumberOfGuids,
LPGUID  lpGuids 
)

Definition at line 776 of file api.cpp.

781{
783 return FALSE;
784}

◆ DeviceProblemWizard_RunDLLA()

VOID WINAPI DeviceProblemWizard_RunDLLA ( HWND  hWndParent,
HINSTANCE  hInst,
LPCSTR  lpDeviceCmd,
int  nCmdShow 
)

Definition at line 652 of file api.cpp.

656{
658}

◆ DeviceProblemWizard_RunDLLW()

VOID WINAPI DeviceProblemWizard_RunDLLW ( HWND  hWndParent,
HINSTANCE  hInst,
LPCWSTR  lpDeviceCmd,
int  nCmdShow 
)

Definition at line 690 of file api.cpp.

694{
696}

◆ DeviceProperties_RunDLLA()

VOID WINAPI DeviceProperties_RunDLLA ( HWND  hWndParent,
HINSTANCE  hInst,
LPCSTR  lpDeviceCmd,
int  nCmdShow 
)

Definition at line 443 of file api.cpp.

447{
448 LPWSTR lpDeviceCmdW = NULL;
449
450 if (lpDeviceCmd != NULL)
451 {
452 if ((lpDeviceCmdW = ConvertMultiByteToUnicode(lpDeviceCmd,
453 CP_ACP)))
454 {
456 hInst,
457 lpDeviceCmdW,
458 nCmdShow);
459 }
460 }
461
462 if (lpDeviceCmdW != NULL)
463 {
465 0,
466 lpDeviceCmdW);
467 }
468}
VOID WINAPI DeviceProperties_RunDLLW(HWND hWndParent, HINSTANCE hInst, LPCWSTR lpDeviceCmd, int nCmdShow)
Definition: api.cpp:498

◆ DeviceProperties_RunDLLW()

VOID WINAPI DeviceProperties_RunDLLW ( HWND  hWndParent,
HINSTANCE  hInst,
LPCWSTR  lpDeviceCmd,
int  nCmdShow 
)

Definition at line 498 of file api.cpp.

502{
503 WCHAR szDeviceID[MAX_DEVICE_ID_LEN + 1];
504 WCHAR szMachineName[MAX_COMPUTERNAME_LENGTH + 1];
505 LPWSTR lpString = (LPWSTR)lpDeviceCmd;
506
507 if (!GetDeviceAndComputerName(lpString,
508 szDeviceID,
509 szMachineName))
510 {
511 ERR("DeviceProperties_RunDLLW DeviceID: %S, MachineName: %S\n", szDeviceID, szMachineName);
512 return;
513 }
514
516 szMachineName,
517 szDeviceID,
518 FALSE);
519}
#define ERR(fmt,...)
Definition: debug.h:113
#define MAX_DEVICE_ID_LEN
Definition: devaction.c:40
int WINAPI DevicePropertiesW(HWND hWndParent, LPCWSTR lpMachineName, LPCWSTR lpDeviceID, BOOL bShowDevMgr)
Definition: api.cpp:403
BOOL GetDeviceAndComputerName(LPWSTR lpString, WCHAR szDeviceID[], WCHAR szMachineName[])
Definition: misc.cpp:1132
#define MAX_COMPUTERNAME_LENGTH
Definition: winbase.h:243
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by DeviceProperties_RunDLLA().

◆ DevicePropertiesA()

int WINAPI DevicePropertiesA ( HWND  hWndParent,
LPCSTR  lpMachineName,
LPCSTR  lpDeviceID,
BOOL  bShowDevMgr 
)

Definition at line 366 of file api.cpp.

370{
372 lpMachineName,
373 lpDeviceID,
375 bShowDevMgr);
376}
INT_PTR WINAPI DevicePropertiesExA(IN HWND hWndParent OPTIONAL, IN LPCSTR lpMachineName OPTIONAL, IN LPCSTR lpDeviceID OPTIONAL, IN DWORD dwFlags OPTIONAL, IN BOOL bShowDevMgr)
Definition: api.cpp:193
#define DPF_EXTENDED
Definition: devmgr.h:144

◆ DevicePropertiesExA()

INT_PTR WINAPI DevicePropertiesExA ( IN HWND hWndParent  OPTIONAL,
IN LPCSTR lpMachineName  OPTIONAL,
IN LPCSTR lpDeviceID  OPTIONAL,
IN DWORD dwFlags  OPTIONAL,
IN BOOL  bShowDevMgr 
)

Definition at line 193 of file api.cpp.

198{
199 LPWSTR lpMachineNameW = NULL;
200 LPWSTR lpDeviceIDW = NULL;
201 INT_PTR Ret = -1;
202
203 if (lpMachineName != NULL)
204 {
205 if (!(lpMachineNameW = ConvertMultiByteToUnicode(lpMachineName,
206 CP_ACP)))
207 {
208 goto Cleanup;
209 }
210 }
211 if (lpDeviceID != NULL)
212 {
213 if (!(lpDeviceIDW = ConvertMultiByteToUnicode(lpDeviceID,
214 CP_ACP)))
215 {
216 goto Cleanup;
217 }
218 }
219
221 lpMachineNameW,
222 lpDeviceIDW,
223 dwFlags,
224 bShowDevMgr);
225
226Cleanup:
227 if (lpMachineNameW != NULL)
228 {
230 0,
231 lpMachineNameW);
232 }
233 if (lpDeviceIDW != NULL)
234 {
236 0,
237 lpDeviceIDW);
238 }
239
240 return Ret;
241}
INT_PTR WINAPI DevicePropertiesExW(IN HWND hWndParent OPTIONAL, IN LPCWSTR lpMachineName OPTIONAL, IN LPCWSTR lpDeviceID OPTIONAL, IN DWORD dwFlags OPTIONAL, IN BOOL bShowDevMgr)
Definition: api.cpp:272
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1176

Referenced by DevicePropertiesA().

◆ DevicePropertiesExW()

INT_PTR WINAPI DevicePropertiesExW ( IN HWND hWndParent  OPTIONAL,
IN LPCWSTR lpMachineName  OPTIONAL,
IN LPCWSTR lpDeviceID  OPTIONAL,
IN DWORD dwFlags  OPTIONAL,
IN BOOL  bShowDevMgr 
)

Definition at line 272 of file api.cpp.

277{
278 INT_PTR Ret = -1;
279
281 {
282 FIXME("DevPropertiesExW: Invalid flags: 0x%x\n",
285 return -1;
286 }
287
288 if (bShowDevMgr)
289 {
290 FIXME("DevPropertiesExW doesn't support bShowDevMgr!\n");
292 }
293 else
294 {
295 HDEVINFO hDevInfo;
296 SP_DEVINFO_DATA DevInfoData;
297 HINSTANCE hComCtl32;
298
299 if (lpDeviceID == NULL)
300 {
302 return -1;
303 }
304
305 /* dynamically load comctl32 */
306 hComCtl32 = LoadAndInitComctl32();
307 if (hComCtl32 != NULL)
308 {
311 lpMachineName,
312 NULL);
313 if (hDevInfo != INVALID_HANDLE_VALUE)
314 {
315 DevInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
316 if (SetupDiOpenDeviceInfo(hDevInfo,
317 lpDeviceID,
319 0,
320 &DevInfoData))
321 {
323 lpDeviceID,
324 hDevInfo,
325 &DevInfoData,
326 hComCtl32,
327 lpMachineName,
328 dwFlags);
329 }
330
332 }
333
334 FreeLibrary(hComCtl32);
335 }
336 }
337
338 return Ret;
339}
#define FIXME(fmt,...)
Definition: debug.h:114
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:102
#define DPF_DEVICE_STATUS_ACTION
Definition: devmgr.h:145
#define ERROR_INVALID_FLAGS
Definition: winerror.h:583

Referenced by DevicePropertiesExA(), DevicePropertiesW(), and CDeviceView::DisplayPropertySheet().

◆ DevicePropertiesW()

int WINAPI DevicePropertiesW ( HWND  hWndParent,
LPCWSTR  lpMachineName,
LPCWSTR  lpDeviceID,
BOOL  bShowDevMgr 
)

Definition at line 403 of file api.cpp.

407{
409 lpMachineName,
410 lpDeviceID,
412 bShowDevMgr);
413}

Referenced by DeviceProperties_RunDLLW().

◆ DllCanUnloadNow()

STDAPI DllCanUnloadNow ( void  )

Definition at line 793 of file api.cpp.

794{
795 return gModule.DllCanUnloadNow();
796}
HRESULT DllCanUnloadNow()
Definition: atlbase.h:1030
CDevMgrUIModule gModule
Definition: api.cpp:791

◆ DllGetClassObject()

STDAPI DllGetClassObject ( REFCLSID  rclsid,
REFIID  riid,
LPVOID ppv 
)

Definition at line 798 of file api.cpp.

799{
800 return gModule.DllGetClassObject(rclsid, riid, ppv);
801}
HRESULT DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
Definition: atlbase.h:1037
REFIID riid
Definition: atlbase.h:39
REFIID LPVOID * ppv
Definition: atlbase.h:39

◆ DllMain()

BOOL WINAPI DllMain ( _In_ HINSTANCE  hinstDLL,
_In_ DWORD  dwReason,
_In_ LPVOID  lpvReserved 
)

Definition at line 817 of file api.cpp.

820{
821 switch (dwReason)
822 {
825 hDllInstance = hinstDLL;
826 break;
827 }
828
829 return TRUE;
830}
DWORD dwReason
Definition: misc.cpp:154
#define TRUE
Definition: types.h:120
#define DLL_PROCESS_ATTACH
Definition: compat.h:131
HINSTANCE hDllInstance
Definition: api.cpp:23
BOOL WINAPI DisableThreadLibraryCalls(IN HMODULE hLibModule)
Definition: loader.c:85

◆ DllRegisterServer()

STDAPI DllRegisterServer ( void  )

Definition at line 803 of file api.cpp.

804{
806}
HRESULT DllRegisterServer(BOOL bRegTypeLib=TRUE)
Definition: atlbase.h:1042

◆ DllUnregisterServer()

STDAPI DllUnregisterServer ( void  )

Definition at line 808 of file api.cpp.

809{
811}
HRESULT DllUnregisterServer(BOOL bUnRegTypeLib=TRUE)
Definition: atlbase.h:1047

Variable Documentation

◆ gModule

◆ hDllInstance

HINSTANCE hDllInstance = NULL

Definition at line 23 of file api.cpp.

Referenced by DllMain().