2 * ReactOS Device Manager Applet
3 * Copyright (C) 2004 - 2005 ReactOS Team
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 /* $Id: hwpage.c 19599 2005-11-26 02:12:58Z weiden $
21 * PROJECT: ReactOS devmgr.dll
22 * FILE: lib/devmgr/advprop.c
23 * PURPOSE: ReactOS Device Manager
24 * PROGRAMMER: Thomas Weidenmueller <w3seek@reactos.com>
33 typedef INT_PTR (WINAPI
*PPROPERTYSHEETW
)(LPCPROPSHEETHEADERW
);
36 DisplayDeviceAdvancedProperties(IN HWND hWndParent
,
37 IN HDEVINFO DeviceInfoSet
,
38 IN PSP_DEVINFO_DATA DeviceInfoData
,
39 IN HINSTANCE hComCtl32
)
43 PROPSHEETHEADER psh
= {0};
44 DWORD nPropSheets
= 0;
45 PPROPERTYSHEETW pPropertySheetW
;
48 pPropertySheetW
= (PPROPERTYSHEETW
)GetProcAddress(hComCtl32
,
50 if (pPropertySheetW
== NULL
)
55 /* get the device name */
56 if ((SetupDiGetDeviceRegistryProperty(DeviceInfoSet
,
63 SetupDiGetDeviceRegistryProperty(DeviceInfoSet
,
70 RegDataType
== REG_SZ
)
72 /* FIXME - check string for NULL termination! */
74 psh
.dwSize
= sizeof(PROPSHEETHEADER
);
75 psh
.dwFlags
= PSH_PROPTITLE
;
76 psh
.hwndParent
= hWndParent
;
77 psh
.pszCaption
= szDevName
;
79 /* find out how many property sheets we need */
80 if (SetupDiGetClassDevPropertySheets(DeviceInfoSet
,
85 DIGCDP_FLAG_ADVANCED
) &&
88 DPRINT1("SetupDiGetClassDevPropertySheets unexpectedly returned TRUE!\n");
92 if (GetLastError() != ERROR_INSUFFICIENT_BUFFER
)
97 psh
.phpage
= HeapAlloc(GetProcessHeap(),
99 nPropSheets
* sizeof(HPROPSHEETPAGE
));
100 if (psh
.phpage
== NULL
)
105 /* FIXME - add the "General" and "Driver" pages */
107 if (!SetupDiGetClassDevPropertySheets(DeviceInfoSet
,
112 DIGCDP_FLAG_ADVANCED
))
117 Ret
= pPropertySheetW(&psh
);
120 HeapFree(GetProcessHeap(),
128 /***************************************************************************
130 * DeviceAdvancedPropertiesW
133 * Invokes the device properties dialog, this version may add some property pages
137 * hWndParent: Handle to the parent window
138 * lpMachineName: Machine Name, NULL is the local machine
139 * lpDeviceID: Specifies the device whose properties are to be shown
142 * -1: if errors occured
152 DeviceAdvancedPropertiesW(HWND hWndParent
,
153 LPCWSTR lpMachineName
,
157 SP_DEVINFO_DATA DevInfoData
;
161 /* FIXME - handle remote device properties */
163 UNREFERENCED_PARAMETER(lpMachineName
);
165 /* dynamically load comctl32 */
166 hComCtl32
= LoadAndInitComctl32();
167 if (hComCtl32
!= NULL
)
169 hDevInfo
= SetupDiCreateDeviceInfoList(NULL
,
171 if (hDevInfo
!= INVALID_HANDLE_VALUE
)
173 DevInfoData
.cbSize
= sizeof(SP_DEVINFO_DATA
);
174 if (SetupDiOpenDeviceInfo(hDevInfo
,
180 Ret
= DisplayDeviceAdvancedProperties(hWndParent
,
186 SetupDiDestroyDeviceInfoList(hDevInfo
);
188 FreeLibrary(hComCtl32
);
194 /***************************************************************************
196 * DeviceAdvancedPropertiesA
199 * Invokes the device properties dialog, this version may add some property pages
203 * hWndParent: Handle to the parent window
204 * lpMachineName: Machine Name, NULL is the local machine
205 * lpDeviceID: Specifies the device whose properties are to be shown
208 * -1: if errors occured
218 DeviceAdvancedPropertiesA(HWND hWndParent
,
219 LPCSTR lpMachineName
,
222 LPWSTR lpMachineNameW
= NULL
;
223 LPWSTR lpDeviceIDW
= NULL
;
226 if (lpMachineName
!= NULL
)
228 if (!(lpMachineNameW
= ConvertMultiByteToUnicode(lpMachineName
,
234 if (lpDeviceID
!= NULL
)
236 if (!(lpDeviceIDW
= ConvertMultiByteToUnicode(lpDeviceID
,
243 Ret
= DeviceAdvancedPropertiesW(hWndParent
,
248 HeapFree(GetProcessHeap(),
251 HeapFree(GetProcessHeap(),