mirror of
https://github.com/reactos/reactos.git
synced 2025-07-31 21:11:54 +00:00
implemented the general device information page
svn path=/trunk/; revision=19646
This commit is contained in:
parent
520fe4b055
commit
c7f5d8268c
6 changed files with 468 additions and 95 deletions
|
@ -29,3 +29,23 @@ BEGIN
|
|||
BS_PUSHBUTTON | WS_CHILD | WS_DISABLED | WS_TABSTOP
|
||||
PUSHBUTTON "P&roperties",IDC_PROPERTIES,146,140,50,14
|
||||
END
|
||||
|
||||
IDD_DEVICEGENERAL DIALOG DISCARDABLE 0, 0, 252, 218
|
||||
STYLE WS_CHILD | WS_DISABLED | WS_CAPTION
|
||||
CAPTION "General"
|
||||
FONT 8, "MS Shell Dlg"
|
||||
BEGIN
|
||||
ICON "", IDC_DEVICON, 7, 7, 20, 20
|
||||
LTEXT "", IDC_DEVNAME, 37, 9, 174, 16, SS_NOPREFIX
|
||||
LTEXT "Device type:", -1, 37, 39, 60, 8, SS_NOPREFIX
|
||||
EDITTEXT IDC_DEVTYPE, 100, 39, 146, 12, NOT WS_TABSTOP | NOT WS_BORDER | ES_AUTOHSCROLL | ES_READONLY
|
||||
LTEXT "Manufacturer:", -1, 37, 53, 60, 8, SS_NOPREFIX
|
||||
EDITTEXT IDC_DEVMANUFACTURER, 100, 53, 145, 12, NOT WS_TABSTOP | NOT WS_BORDER | ES_AUTOHSCROLL | ES_READONLY
|
||||
LTEXT "Location:", -1, 37, 67, 60, 8, SS_NOPREFIX
|
||||
EDITTEXT IDC_DEVLOCATION, 100, 67, 145, 12, NOT WS_TABSTOP | NOT WS_BORDER | ES_AUTOHSCROLL | ES_READONLY
|
||||
GROUPBOX "Device status", IDC_DEVSTATUSGROUP, 7, 83, 238, 100
|
||||
EDITTEXT IDC_DEVSTATUS, 14, 96, 224, 61, NOT WS_TABSTOP | ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY | WS_VSCROLL
|
||||
PUSHBUTTON "&Troubleshoot...", IDC_TROUBLESHOOT, 148, 163, 90, 15
|
||||
LTEXT "&Device usage:", -1, 7, 188, 222, 8
|
||||
COMBOBOX IDC_DEVUSAGE, 7, 198, 239, 40, CBS_DROPDOWN | WS_VSCROLL
|
||||
END
|
||||
|
|
|
@ -31,6 +31,130 @@
|
|||
#include <debug.h>
|
||||
|
||||
typedef INT_PTR (WINAPI *PPROPERTYSHEETW)(LPCPROPSHEETHEADERW);
|
||||
typedef HPROPSHEETPAGE (WINAPI *PCREATEPROPERTYSHEETPAGEW)(LPCPROPSHEETPAGEW);
|
||||
typedef BOOL (WINAPI *PDESTROYPROPERTYSHEETPAGE)(HPROPSHEETPAGE);
|
||||
|
||||
typedef struct _DEVADVPROP_INFO
|
||||
{
|
||||
HDEVINFO DeviceInfoSet;
|
||||
PSP_DEVINFO_DATA DeviceInfoData;
|
||||
HINSTANCE hComCtl32;
|
||||
WCHAR szDevName[255];
|
||||
WCHAR szTemp[255];
|
||||
} DEVADVPROP_INFO, *PDEVADVPROP_INFO;
|
||||
|
||||
|
||||
static INT_PTR
|
||||
CALLBACK
|
||||
AdvPropGeneralDlgProc(IN HWND hwndDlg,
|
||||
IN UINT uMsg,
|
||||
IN WPARAM wParam,
|
||||
IN LPARAM lParam)
|
||||
{
|
||||
PDEVADVPROP_INFO dap;
|
||||
|
||||
dap = (PDEVADVPROP_INFO)GetWindowLongPtr(hwndDlg,
|
||||
DWL_USER);
|
||||
|
||||
if (dap != NULL || uMsg == WM_INITDIALOG)
|
||||
{
|
||||
switch (uMsg)
|
||||
{
|
||||
case WM_INITDIALOG:
|
||||
{
|
||||
dap = (PDEVADVPROP_INFO)((LPPROPSHEETPAGE)lParam)->lParam;
|
||||
if (dap != NULL)
|
||||
{
|
||||
HICON hIcon;
|
||||
|
||||
SetWindowLongPtr(hwndDlg,
|
||||
DWL_USER,
|
||||
(DWORD_PTR)dap);
|
||||
|
||||
/* set the device image */
|
||||
if (SetupDiLoadClassIcon(&dap->DeviceInfoData->ClassGuid,
|
||||
&hIcon,
|
||||
NULL))
|
||||
{
|
||||
SendDlgItemMessage(hwndDlg,
|
||||
IDC_DEVICON,
|
||||
STM_SETICON,
|
||||
(WPARAM)hIcon,
|
||||
0);
|
||||
}
|
||||
|
||||
/* set the device name edit control text */
|
||||
SetDlgItemText(hwndDlg,
|
||||
IDC_DEVNAME,
|
||||
dap->szDevName);
|
||||
|
||||
/* set the device type edit control text */
|
||||
if (GetDeviceTypeString(dap->DeviceInfoData,
|
||||
dap->szTemp,
|
||||
sizeof(dap->szTemp) / sizeof(dap->szTemp[0])))
|
||||
{
|
||||
SetDlgItemText(hwndDlg,
|
||||
IDC_DEVTYPE,
|
||||
dap->szTemp);
|
||||
}
|
||||
|
||||
/* set the device manufacturer edit control text */
|
||||
if (GetDeviceManufacturerString(dap->DeviceInfoSet,
|
||||
dap->DeviceInfoData,
|
||||
dap->szTemp,
|
||||
sizeof(dap->szTemp) / sizeof(dap->szTemp[0])))
|
||||
{
|
||||
SetDlgItemText(hwndDlg,
|
||||
IDC_DEVMANUFACTURER,
|
||||
dap->szTemp);
|
||||
}
|
||||
|
||||
/* set the device location edit control text */
|
||||
if (GetDeviceLocationString(dap->DeviceInfoData->DevInst,
|
||||
dap->szTemp,
|
||||
sizeof(dap->szTemp) / sizeof(dap->szTemp[0])))
|
||||
{
|
||||
SetDlgItemText(hwndDlg,
|
||||
IDC_DEVLOCATION,
|
||||
dap->szTemp);
|
||||
}
|
||||
|
||||
/* set the device status edit control text */
|
||||
if (GetDeviceStatusString(dap->DeviceInfoSet,
|
||||
dap->DeviceInfoData,
|
||||
dap->szTemp,
|
||||
sizeof(dap->szTemp) / sizeof(dap->szTemp[0])))
|
||||
{
|
||||
SetDlgItemText(hwndDlg,
|
||||
IDC_DEVSTATUS,
|
||||
dap->szTemp);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case WM_DESTROY:
|
||||
{
|
||||
HICON hDevIcon;
|
||||
|
||||
/* destroy the device icon */
|
||||
hDevIcon = (HICON)SendDlgItemMessage(hwndDlg,
|
||||
IDC_DEVICON,
|
||||
STM_GETICON,
|
||||
0,
|
||||
0);
|
||||
if (hDevIcon != NULL)
|
||||
{
|
||||
DestroyIcon(hDevIcon);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
INT_PTR
|
||||
DisplayDeviceAdvancedProperties(IN HWND hWndParent,
|
||||
|
@ -38,34 +162,74 @@ DisplayDeviceAdvancedProperties(IN HWND hWndParent,
|
|||
IN PSP_DEVINFO_DATA DeviceInfoData,
|
||||
IN HINSTANCE hComCtl32)
|
||||
{
|
||||
WCHAR szDevName[255];
|
||||
DWORD RegDataType;
|
||||
PROPSHEETHEADER psh = {0};
|
||||
PROPSHEETPAGE pspGeneral = {0};
|
||||
DWORD nPropSheets = 0;
|
||||
DWORD nDevSheetsStart = 0;
|
||||
PPROPERTYSHEETW pPropertySheetW;
|
||||
PCREATEPROPERTYSHEETPAGEW pCreatePropertySheetPageW;
|
||||
PDESTROYPROPERTYSHEETPAGE pDestroyPropertySheetPage;
|
||||
PDEVADVPROP_INFO DevAdvPropInfo;
|
||||
UINT nPages = 0;
|
||||
union
|
||||
{
|
||||
ULONG Mask;
|
||||
struct
|
||||
{
|
||||
ULONG General : 1;
|
||||
ULONG Device : 1;
|
||||
} Page;
|
||||
} DelPropSheets = {0};
|
||||
INT_PTR Ret = -1;
|
||||
|
||||
pPropertySheetW = (PPROPERTYSHEETW)GetProcAddress(hComCtl32,
|
||||
"PropertySheetW");
|
||||
if (pPropertySheetW == NULL)
|
||||
/* we don't want to statically link against comctl32, so find the
|
||||
functions we need dynamically */
|
||||
pPropertySheetW =
|
||||
(PPROPERTYSHEETW)GetProcAddress(hComCtl32,
|
||||
"PropertySheetW");
|
||||
pCreatePropertySheetPageW =
|
||||
(PCREATEPROPERTYSHEETPAGEW)GetProcAddress(hComCtl32,
|
||||
"CreatePropertySheetPageW");
|
||||
pDestroyPropertySheetPage =
|
||||
(PDESTROYPROPERTYSHEETPAGE)GetProcAddress(hComCtl32,
|
||||
"DestroyPropertySheetPage");
|
||||
if (pPropertySheetW == NULL ||
|
||||
pCreatePropertySheetPageW == NULL ||
|
||||
pDestroyPropertySheetPage == NULL)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* create the internal structure associated with the "General",
|
||||
"Driver", ... pages */
|
||||
DevAdvPropInfo = HeapAlloc(GetProcessHeap(),
|
||||
0,
|
||||
sizeof(DEVADVPROP_INFO));
|
||||
if (DevAdvPropInfo == NULL)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
DevAdvPropInfo->DeviceInfoSet = DeviceInfoSet;
|
||||
DevAdvPropInfo->DeviceInfoData = DeviceInfoData;
|
||||
DevAdvPropInfo->hComCtl32 = hComCtl32;
|
||||
DevAdvPropInfo->szDevName[0] = L'\0';
|
||||
|
||||
/* get the device name */
|
||||
if ((SetupDiGetDeviceRegistryProperty(DeviceInfoSet,
|
||||
DeviceInfoData,
|
||||
SPDRP_FRIENDLYNAME,
|
||||
&RegDataType,
|
||||
(PBYTE)szDevName,
|
||||
sizeof(szDevName),
|
||||
(PBYTE)DevAdvPropInfo->szDevName,
|
||||
sizeof(DevAdvPropInfo->szDevName),
|
||||
NULL) ||
|
||||
SetupDiGetDeviceRegistryProperty(DeviceInfoSet,
|
||||
DeviceInfoData,
|
||||
SPDRP_DEVICEDESC,
|
||||
&RegDataType,
|
||||
(PBYTE)szDevName,
|
||||
sizeof(szDevName),
|
||||
(PBYTE)DevAdvPropInfo->szDevName,
|
||||
sizeof(DevAdvPropInfo->szDevName),
|
||||
NULL)) &&
|
||||
RegDataType == REG_SZ)
|
||||
{
|
||||
|
@ -74,7 +238,7 @@ DisplayDeviceAdvancedProperties(IN HWND hWndParent,
|
|||
psh.dwSize = sizeof(PROPSHEETHEADER);
|
||||
psh.dwFlags = PSH_PROPTITLE;
|
||||
psh.hwndParent = hWndParent;
|
||||
psh.pszCaption = szDevName;
|
||||
psh.pszCaption = DevAdvPropInfo->szDevName;
|
||||
|
||||
/* find out how many property sheets we need */
|
||||
if (SetupDiGetClassDevPropertySheets(DeviceInfoSet,
|
||||
|
@ -89,42 +253,100 @@ DisplayDeviceAdvancedProperties(IN HWND hWndParent,
|
|||
goto Cleanup;
|
||||
}
|
||||
|
||||
if (GetLastError() != ERROR_INSUFFICIENT_BUFFER)
|
||||
if (nPropSheets != 0 && GetLastError() != ERROR_INSUFFICIENT_BUFFER)
|
||||
{
|
||||
goto Cleanup;
|
||||
}
|
||||
|
||||
psh.phpage = HeapAlloc(GetProcessHeap(),
|
||||
0,
|
||||
nPropSheets * sizeof(HPROPSHEETPAGE));
|
||||
HEAP_ZERO_MEMORY,
|
||||
(nPropSheets + 1) * sizeof(HPROPSHEETPAGE));
|
||||
if (psh.phpage == NULL)
|
||||
{
|
||||
goto Cleanup;
|
||||
}
|
||||
|
||||
/* FIXME - add the "General" and "Driver" pages */
|
||||
|
||||
if (!SetupDiGetClassDevPropertySheets(DeviceInfoSet,
|
||||
DeviceInfoData,
|
||||
&psh,
|
||||
nPropSheets,
|
||||
NULL,
|
||||
DIGCDP_FLAG_ADVANCED))
|
||||
/* add the "General" property sheet */
|
||||
pspGeneral.dwSize = sizeof(PROPSHEETPAGE);
|
||||
pspGeneral.dwFlags = PSP_DEFAULT;
|
||||
pspGeneral.hInstance = hDllInstance;
|
||||
pspGeneral.pszTemplate = (LPCWSTR)MAKEINTRESOURCE(IDD_DEVICEGENERAL);
|
||||
pspGeneral.pfnDlgProc = AdvPropGeneralDlgProc;
|
||||
pspGeneral.lParam = (LPARAM)DevAdvPropInfo;
|
||||
psh.phpage[0] = pCreatePropertySheetPageW(&pspGeneral);
|
||||
if (psh.phpage[0] != NULL)
|
||||
{
|
||||
goto Cleanup;
|
||||
DelPropSheets.Page.General = TRUE;
|
||||
nDevSheetsStart++;
|
||||
nPages++;
|
||||
}
|
||||
|
||||
if (nPropSheets != 0)
|
||||
{
|
||||
/* create the device property sheets but don't overwrite
|
||||
the "General" property sheet handle */
|
||||
psh.phpage += nDevSheetsStart;
|
||||
if (!SetupDiGetClassDevPropertySheets(DeviceInfoSet,
|
||||
DeviceInfoData,
|
||||
&psh,
|
||||
nPropSheets,
|
||||
NULL,
|
||||
DIGCDP_FLAG_ADVANCED))
|
||||
{
|
||||
goto Cleanup;
|
||||
}
|
||||
psh.phpage -= nDevSheetsStart;
|
||||
|
||||
DelPropSheets.Page.Device = TRUE;
|
||||
nPages += nPropSheets;
|
||||
}
|
||||
|
||||
psh.nPages = nPages;
|
||||
|
||||
/* FIXME - add the "Driver" property sheet if necessary */
|
||||
|
||||
Ret = pPropertySheetW(&psh);
|
||||
|
||||
/* no need to destroy the property sheets anymore */
|
||||
DelPropSheets.Mask = 0;
|
||||
|
||||
Cleanup:
|
||||
/* in case of failure the property sheets must be destroyed */
|
||||
if (DelPropSheets.Mask != 0)
|
||||
{
|
||||
if (DelPropSheets.Page.General && psh.phpage[0] != NULL)
|
||||
{
|
||||
pDestroyPropertySheetPage(psh.phpage[0]);
|
||||
}
|
||||
|
||||
if (DelPropSheets.Page.Device)
|
||||
{
|
||||
UINT i;
|
||||
for (i = 0;
|
||||
i < nPropSheets;
|
||||
i++)
|
||||
{
|
||||
if (psh.phpage[i + 1] != NULL)
|
||||
{
|
||||
pDestroyPropertySheetPage(psh.phpage[i + 1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
HeapFree(GetProcessHeap(),
|
||||
0,
|
||||
psh.phpage);
|
||||
}
|
||||
|
||||
HeapFree(GetProcessHeap(),
|
||||
0,
|
||||
DevAdvPropInfo);
|
||||
|
||||
return Ret;
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
* NAME EXPORTED
|
||||
* DeviceAdvancedPropertiesW
|
||||
|
@ -177,6 +399,8 @@ DeviceAdvancedPropertiesW(HWND hWndParent,
|
|||
0,
|
||||
&DevInfoData))
|
||||
{
|
||||
|
||||
/* create the image list */
|
||||
Ret = DisplayDeviceAdvancedProperties(hWndParent,
|
||||
hDevInfo,
|
||||
&DevInfoData,
|
||||
|
@ -185,12 +409,14 @@ DeviceAdvancedPropertiesW(HWND hWndParent,
|
|||
|
||||
SetupDiDestroyDeviceInfoList(hDevInfo);
|
||||
}
|
||||
|
||||
FreeLibrary(hComCtl32);
|
||||
}
|
||||
|
||||
return Ret;
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
* NAME EXPORTED
|
||||
* DeviceAdvancedPropertiesA
|
||||
|
|
|
@ -158,30 +158,15 @@ UpdateControlStates(IN PHARDWARE_PAGE_DATA hpd)
|
|||
if (HwDevInfo != NULL)
|
||||
{
|
||||
/* update static controls */
|
||||
CONFIGRET cRet;
|
||||
DWORD RegDataType;
|
||||
ULONG DataSize;
|
||||
WCHAR szBuffer[256];
|
||||
LPWSTR szFormatted = NULL;
|
||||
|
||||
/* get the manufacturer string */
|
||||
if (!SetupDiGetDeviceRegistryProperty(HwDevInfo->ClassDevInfo->hDevInfo,
|
||||
&HwDevInfo->DevInfoData,
|
||||
SPDRP_MFG,
|
||||
&RegDataType,
|
||||
(PBYTE)szBuffer,
|
||||
sizeof(szBuffer),
|
||||
NULL) ||
|
||||
RegDataType != REG_SZ)
|
||||
{
|
||||
szBuffer[0] = L'\0';
|
||||
LoadString(hDllInstance,
|
||||
IDS_UNKNOWN,
|
||||
szBuffer,
|
||||
sizeof(szBuffer) / sizeof(szBuffer[0]));
|
||||
}
|
||||
/* FIXME - check string for NULL termination! */
|
||||
if (LoadAndFormatString(hDllInstance,
|
||||
if (GetDeviceManufacturerString(HwDevInfo->ClassDevInfo->hDevInfo,
|
||||
&HwDevInfo->DevInfoData,
|
||||
szBuffer,
|
||||
sizeof(szBuffer) / sizeof(szBuffer[0])) &&
|
||||
LoadAndFormatString(hDllInstance,
|
||||
IDS_MANUFACTURER,
|
||||
&szFormatted,
|
||||
szBuffer) != 0)
|
||||
|
@ -193,46 +178,10 @@ UpdateControlStates(IN PHARDWARE_PAGE_DATA hpd)
|
|||
}
|
||||
|
||||
/* get the location string */
|
||||
DataSize = sizeof(szBuffer);
|
||||
cRet = CM_Get_DevNode_Registry_Property(HwDevInfo->DevInfoData.DevInst,
|
||||
CM_DRP_LOCATION_INFORMATION,
|
||||
&RegDataType,
|
||||
szBuffer,
|
||||
&DataSize,
|
||||
0);
|
||||
if (cRet != CR_SUCCESS ||
|
||||
RegDataType != REG_SZ)
|
||||
{
|
||||
szBuffer[0] = L'\0';
|
||||
LoadString(hDllInstance,
|
||||
IDS_UNKNOWN,
|
||||
szBuffer,
|
||||
sizeof(szBuffer) / sizeof(szBuffer[0]));
|
||||
}
|
||||
/* FIXME - check string for NULL termination! */
|
||||
|
||||
if (szBuffer[0] >= L'0' && szBuffer[0] <= L'9')
|
||||
{
|
||||
/* convert the string to an integer value and create a
|
||||
formatted string */
|
||||
ULONG ulLocation = (ULONG)wcstoul(szBuffer,
|
||||
NULL,
|
||||
10);
|
||||
if (LoadAndFormatString(hDllInstance,
|
||||
IDS_LOCATIONSTR,
|
||||
&szFormatted,
|
||||
ulLocation,
|
||||
szBuffer) != 0)
|
||||
{
|
||||
wcsncpy(szBuffer,
|
||||
szFormatted,
|
||||
(sizeof(szBuffer) / sizeof(szBuffer[0])) - 1);
|
||||
szBuffer[(sizeof(szBuffer) / sizeof(szBuffer[0])) - 1] = L'\0';
|
||||
LocalFree((HLOCAL)szFormatted);
|
||||
}
|
||||
}
|
||||
|
||||
if (LoadAndFormatString(hDllInstance,
|
||||
if (GetDeviceLocationString(HwDevInfo->DevInfoData.DevInst,
|
||||
szBuffer,
|
||||
sizeof(szBuffer) / sizeof(szBuffer[0])) &&
|
||||
LoadAndFormatString(hDllInstance,
|
||||
IDS_LOCATION,
|
||||
&szFormatted,
|
||||
szBuffer) != 0)
|
||||
|
@ -243,13 +192,11 @@ UpdateControlStates(IN PHARDWARE_PAGE_DATA hpd)
|
|||
LocalFree((HLOCAL)szFormatted);
|
||||
}
|
||||
|
||||
/* FIXME - get the device status text */
|
||||
LoadString(hDllInstance,
|
||||
IDS_UNKNOWN,
|
||||
szBuffer,
|
||||
sizeof(szBuffer) / sizeof(szBuffer[0]));
|
||||
|
||||
if (LoadAndFormatString(hDllInstance,
|
||||
if (GetDeviceStatusString(HwDevInfo->ClassDevInfo->hDevInfo,
|
||||
&HwDevInfo->DevInfoData,
|
||||
szBuffer,
|
||||
sizeof(szBuffer) / sizeof(szBuffer[0])) &&
|
||||
LoadAndFormatString(hDllInstance,
|
||||
IDS_STATUS,
|
||||
&szFormatted,
|
||||
szBuffer) != 0)
|
||||
|
@ -449,10 +396,9 @@ FillDevicesListViewControl(IN PHARDWARE_PAGE_DATA hpd)
|
|||
ItemCount++;
|
||||
|
||||
/* get the device type for the second column */
|
||||
if (SetupDiGetClassDescription(&ClassDevInfo->Guid,
|
||||
szBuffer,
|
||||
sizeof(szBuffer) / sizeof(szBuffer[0]),
|
||||
NULL))
|
||||
if (GetDeviceTypeString(&HwDevInfo->DevInfoData,
|
||||
szBuffer,
|
||||
sizeof(szBuffer) / sizeof(szBuffer[0])))
|
||||
{
|
||||
li.mask = LVIF_TEXT;
|
||||
li.iItem = iItem;
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
|
||||
HINSTANCE hDllInstance = NULL;
|
||||
|
||||
|
||||
static INT
|
||||
LengthOfStrResource(IN HINSTANCE hInst,
|
||||
IN UINT uID)
|
||||
|
@ -65,6 +66,7 @@ LengthOfStrResource(IN HINSTANCE hInst,
|
|||
return -1;
|
||||
}
|
||||
|
||||
|
||||
static INT
|
||||
AllocAndLoadString(OUT LPWSTR *lpTarget,
|
||||
IN HINSTANCE hInst,
|
||||
|
@ -91,6 +93,7 @@ AllocAndLoadString(OUT LPWSTR *lpTarget,
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
DWORD
|
||||
LoadAndFormatString(IN HINSTANCE hInstance,
|
||||
IN UINT uID,
|
||||
|
@ -123,6 +126,7 @@ LoadAndFormatString(IN HINSTANCE hInstance,
|
|||
return Ret;
|
||||
}
|
||||
|
||||
|
||||
LPARAM
|
||||
ListViewGetSelectedItemData(IN HWND hwnd)
|
||||
{
|
||||
|
@ -149,6 +153,7 @@ ListViewGetSelectedItemData(IN HWND hwnd)
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
LPWSTR
|
||||
ConvertMultiByteToUnicode(IN LPCSTR lpMultiByteStr,
|
||||
IN UINT uCodePage)
|
||||
|
@ -187,6 +192,151 @@ ConvertMultiByteToUnicode(IN LPCSTR lpMultiByteStr,
|
|||
return lpUnicodeStr;
|
||||
}
|
||||
|
||||
|
||||
BOOL
|
||||
GetDeviceManufacturerString(IN HDEVINFO DeviceInfoSet,
|
||||
IN PSP_DEVINFO_DATA DeviceInfoData,
|
||||
OUT LPWSTR szBuffer,
|
||||
IN DWORD BufferSize)
|
||||
{
|
||||
DWORD RegDataType;
|
||||
BOOL Ret = FALSE;
|
||||
|
||||
if (!SetupDiGetDeviceRegistryProperty(DeviceInfoSet,
|
||||
DeviceInfoData,
|
||||
SPDRP_MFG,
|
||||
&RegDataType,
|
||||
(PBYTE)szBuffer,
|
||||
BufferSize * sizeof(WCHAR),
|
||||
NULL) ||
|
||||
RegDataType != REG_SZ)
|
||||
{
|
||||
szBuffer[0] = L'\0';
|
||||
if (LoadString(hDllInstance,
|
||||
IDS_UNKNOWN,
|
||||
szBuffer,
|
||||
BufferSize))
|
||||
{
|
||||
Ret = TRUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* FIXME - check string for NULL termination! */
|
||||
Ret = TRUE;
|
||||
}
|
||||
|
||||
return Ret;
|
||||
}
|
||||
|
||||
|
||||
BOOL
|
||||
GetDeviceLocationString(IN DEVINST dnDevInst,
|
||||
OUT LPWSTR szBuffer,
|
||||
IN DWORD BufferSize)
|
||||
{
|
||||
DWORD RegDataType;
|
||||
ULONG DataSize;
|
||||
CONFIGRET cRet;
|
||||
BOOL Ret = FALSE;
|
||||
|
||||
DataSize = BufferSize * sizeof(WCHAR);
|
||||
cRet = CM_Get_DevNode_Registry_Property(dnDevInst,
|
||||
CM_DRP_LOCATION_INFORMATION,
|
||||
&RegDataType,
|
||||
szBuffer,
|
||||
&DataSize,
|
||||
0);
|
||||
if (cRet != CR_SUCCESS ||
|
||||
RegDataType != REG_SZ)
|
||||
{
|
||||
szBuffer[0] = L'\0';
|
||||
if (LoadString(hDllInstance,
|
||||
IDS_UNKNOWN,
|
||||
szBuffer,
|
||||
BufferSize))
|
||||
{
|
||||
Ret = TRUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* FIXME - check string for NULL termination! */
|
||||
Ret = TRUE;
|
||||
}
|
||||
|
||||
if (szBuffer[0] >= L'0' && szBuffer[0] <= L'9')
|
||||
{
|
||||
/* convert the string to an integer value and create a
|
||||
formatted string */
|
||||
LPWSTR szFormatted;
|
||||
ULONG ulLocation = (ULONG)wcstoul(szBuffer,
|
||||
NULL,
|
||||
10);
|
||||
if (LoadAndFormatString(hDllInstance,
|
||||
IDS_LOCATIONSTR,
|
||||
&szFormatted,
|
||||
ulLocation,
|
||||
szBuffer) != 0)
|
||||
{
|
||||
wcsncpy(szBuffer,
|
||||
szFormatted,
|
||||
BufferSize - 1);
|
||||
szBuffer[BufferSize - 1] = L'\0';
|
||||
LocalFree((HLOCAL)szFormatted);
|
||||
}
|
||||
else
|
||||
Ret = FALSE;
|
||||
}
|
||||
|
||||
return Ret;
|
||||
}
|
||||
|
||||
|
||||
BOOL
|
||||
GetDeviceStatusString(IN HDEVINFO DeviceInfoSet,
|
||||
IN PSP_DEVINFO_DATA DeviceInfoData,
|
||||
OUT LPWSTR szBuffer,
|
||||
IN DWORD BufferSize)
|
||||
{
|
||||
return LoadString(hDllInstance,
|
||||
IDS_UNKNOWN,
|
||||
szBuffer,
|
||||
BufferSize) != 0;
|
||||
}
|
||||
|
||||
|
||||
BOOL
|
||||
GetDeviceTypeString(IN PSP_DEVINFO_DATA DeviceInfoData,
|
||||
OUT LPWSTR szBuffer,
|
||||
IN DWORD BufferSize)
|
||||
{
|
||||
BOOL Ret = FALSE;
|
||||
|
||||
if (!SetupDiGetClassDescription(&DeviceInfoData->ClassGuid,
|
||||
szBuffer,
|
||||
BufferSize,
|
||||
NULL))
|
||||
{
|
||||
szBuffer[0] = L'\0';
|
||||
if (LoadString(hDllInstance,
|
||||
IDS_UNKNOWN,
|
||||
szBuffer,
|
||||
BufferSize))
|
||||
{
|
||||
Ret = TRUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* FIXME - check string for NULL termination! */
|
||||
Ret = TRUE;
|
||||
}
|
||||
|
||||
return Ret;
|
||||
}
|
||||
|
||||
|
||||
HINSTANCE
|
||||
LoadAndInitComctl32(VOID)
|
||||
{
|
||||
|
@ -212,6 +362,7 @@ LoadAndInitComctl32(VOID)
|
|||
return hComCtl32;
|
||||
}
|
||||
|
||||
|
||||
BOOL
|
||||
STDCALL
|
||||
DllMain(IN HINSTANCE hinstDLL,
|
||||
|
|
|
@ -206,6 +206,28 @@ ConvertMultiByteToUnicode(IN LPCSTR lpMultiByteStr,
|
|||
HINSTANCE
|
||||
LoadAndInitComctl32(VOID);
|
||||
|
||||
BOOL
|
||||
GetDeviceManufacturerString(IN HDEVINFO DeviceInfoSet,
|
||||
IN PSP_DEVINFO_DATA DeviceInfoData,
|
||||
OUT LPWSTR szBuffer,
|
||||
IN DWORD BufferSize);
|
||||
|
||||
BOOL
|
||||
GetDeviceLocationString(IN DEVINST dnDevInst,
|
||||
OUT LPWSTR szBuffer,
|
||||
IN DWORD BufferSize);
|
||||
|
||||
BOOL
|
||||
GetDeviceStatusString(IN HDEVINFO DeviceInfoSet,
|
||||
IN PSP_DEVINFO_DATA DeviceInfoData,
|
||||
OUT LPWSTR szBuffer,
|
||||
IN DWORD BufferSize);
|
||||
|
||||
BOOL
|
||||
GetDeviceTypeString(IN PSP_DEVINFO_DATA DeviceInfoData,
|
||||
OUT LPWSTR szBuffer,
|
||||
IN DWORD BufferSize);
|
||||
|
||||
#endif /* __DEVMGR_H */
|
||||
|
||||
/* EOF */
|
||||
|
|
|
@ -2,10 +2,18 @@
|
|||
#define __DEVMGR_RESOURCE_H
|
||||
|
||||
#define IDI_DEVMGR 100
|
||||
#define IDD_HARDWARE 100
|
||||
|
||||
/* control IDs *must* match, some windows components
|
||||
seem to use them... */
|
||||
#define IDD_HARDWARE 100
|
||||
#define IDD_DEVICEGENERAL 101
|
||||
|
||||
#define IDC_DEVICON 0x57B
|
||||
#define IDC_DEVNAME 0x57C
|
||||
#define IDC_DEVTYPE 0x57D
|
||||
#define IDC_DEVMANUFACTURER 0x57E
|
||||
#define IDC_DEVLOCATION 0x57F
|
||||
#define IDC_DEVSTATUSGROUP 0x580
|
||||
#define IDC_DEVSTATUS 0x581
|
||||
#define IDC_DEVUSAGE 0x582
|
||||
#define IDC_DEVICES 0x583
|
||||
#define IDC_LV_DEVICES 0x584
|
||||
#define IDC_PROPERTIESGROUP 0x585
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue