Initial implementation of the hardware page, based on a patch by Gąsiorek <zebasoftis@reactos.org> (bug #986)

svn path=/trunk/; revision=19551
This commit is contained in:
Thomas Bluemel 2005-11-25 14:17:30 +00:00
parent 790caeda87
commit 75507318d0
9 changed files with 1057 additions and 106 deletions

28
reactos/lib/devmgr/En.rc Normal file
View file

@ -0,0 +1,28 @@
// English language resource file (Sebastian Gasiorek, 2005-11-13)
LANGUAGE LANG_ENGLISH, SUBLANG_DEFAULT
STRINGTABLE
BEGIN
IDS_NAME "Name"
IDS_TYPE "Type"
IDS_MANUFACTURER "Manufacturer: %1"
IDS_LOCATION "Location: %1"
IDS_STATUS "Device Status: %1"
END
IDD_HARDWARE DIALOG DISCARDABLE 0, 0, 300, 400
STYLE DS_3DLOOK | DS_CONTROL | WS_CHILD | WS_VISIBLE | WS_CAPTION | DS_SHELLFONT
FONT 8, "MS Shell Dlg"
BEGIN
LTEXT "&Devices:",IDC_DEVICES,7,6,196,10
CONTROL "",IDC_LV_DEVICES,"SysListView32",LVS_REPORT |
LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_SHAREIMAGELISTS |
LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,7,16,196,50
GROUPBOX "Device Properties",IDC_PROPERTIESGROUP,7,76,196,105
LTEXT "",IDC_MANUFACTURER,14,88,183,10,SS_ENDELLIPSIS
LTEXT "",IDC_LOCATION,14,100,183,10,SS_ENDELLIPSIS
LTEXT "",IDC_STATUS,14,112,183,30
PUSHBUTTON "&Troubleshoot...",IDC_TROUBLESHOOT,85,140,54,14
PUSHBUTTON "P&roperties",IDC_PROPERTIES,146,140,50,14
END

28
reactos/lib/devmgr/Pl.rc Normal file
View file

@ -0,0 +1,28 @@
// Polish language resource file (Sebastian Gasiorek, 2005-11-13)
LANGUAGE LANG_POLISH, SUBLANG_DEFAULT
STRINGTABLE
BEGIN
IDS_NAME "Nazwa"
IDS_TYPE "Typ"
IDS_MANUFACTURER "Producent: %1"
IDS_LOCATION "Lokalizacja: %1"
IDS_STATUS "Stan urz¹dzenia: %1"
END
IDD_HARDWARE DIALOG DISCARDABLE 0, 0, 300, 400
STYLE DS_3DLOOK | DS_CONTROL | WS_CHILD | WS_VISIBLE | WS_CAPTION | DS_SHELLFONT
FONT 8, "MS Shell Dlg"
BEGIN
LTEXT "&Urz¹dzenia:",IDC_DEVICES,7,6,196,10
CONTROL "",IDC_LV_DEVICES,"SysListView32",LVS_REPORT |
LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_SHAREIMAGELISTS |
LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,7,16,196,50
GROUPBOX "W³aœciwoœci urz¹dzenia",IDC_PROPERTIESGROUP,7,76,196,105
LTEXT "",IDC_MANUFACTURER,14,88,183,10,SS_ENDELLIPSIS
LTEXT "",IDC_LOCATION,14,100,183,10,SS_ENDELLIPSIS
LTEXT "",IDC_STATUS,14,112,183,30
PUSHBUTTON "&Rozwi¹zywanie problemów...",IDC_TROUBLESHOOT,85,140,54,14
PUSHBUTTON "&W³aœciwoœci",IDC_PROPERTIES,146,140,50,14
END

View file

@ -1,6 +1,6 @@
/*
* ReactOS Device Manager Applet
* Copyright (C) 2004 ReactOS Team
* Copyright (C) 2004 - 2005 ReactOS Team
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -21,35 +21,807 @@
* PROJECT: ReactOS devmgr.dll
* FILE: lib/devmgr/devmgr.c
* PURPOSE: ReactOS Device Manager
* PROGRAMMER: Thomas Weidenmueller (w3seek@users.sourceforge.net)
* PROGRAMMER: Thomas Weidenmueller <w3seek@reactos.com>
* UPDATE HISTORY:
* 04-04-2004 Created
*/
#include <windows.h>
#include "devmgr.h"
#include "resource.h"
#include <precomp.h>
HINSTANCE hDllInstance;
#define NDEBUG
#include <debug.h>
HINSTANCE hDllInstance = NULL;
BOOL STDCALL
DllMain(
HINSTANCE hinstDLL,
DWORD dwReason,
LPVOID lpvReserved)
typedef VOID (WINAPI *PINITCOMMONCONTROLS)(VOID);
typedef enum
{
switch (dwReason)
{
case DLL_PROCESS_ATTACH:
hDllInstance = hinstDLL;
break;
case DLL_THREAD_ATTACH:
break;
case DLL_THREAD_DETACH:
break;
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
HWPD_STANDARDLIST = 0,
HWPD_LARGELIST,
HWPD_MAX = HWPD_LARGELIST
} HWPAGE_DISPLAYMODE, *PHWPAGE_DISPLAYMODE;
typedef struct _HWDEVINFO
{
struct _HWCLASSDEVINFO *ClassDevInfo;
SP_DEVINFO_DATA DevInfoData;
} HWDEVINFO, *PHWDEVINFO;
typedef struct _HWCLASSDEVINFO
{
GUID Guid;
HDEVINFO hDevInfo;
INT ItemCount;
PHWDEVINFO HwDevInfo;
} HWCLASSDEVINFO, *PHWCLASSDEVINFO;
typedef struct _HARDWARE_PAGE_DATA
{
HWND hWnd;
HWND hWndDevList;
HINSTANCE hComCtl32; /* only save this to keep track of the references */
SP_CLASSIMAGELIST_DATA ClassImageListData;
HWPAGE_DISPLAYMODE DisplayMode;
/* parent window subclass info */
WNDPROC ParentOldWndProc;
HWND hWndParent;
UINT NumberOfGuids;
HWCLASSDEVINFO ClassDevInfo[1];
/* struct may be dynamically expanded here! */
} HARDWARE_PAGE_DATA, *PHARDWARE_PAGE_DATA;
#define CX_TYPECOLUMN_WIDTH 80
static VOID
InitializeDevicesList(IN PHARDWARE_PAGE_DATA hpd)
{
LVCOLUMN lvc;
RECT rcClient;
WCHAR szColName[255];
int iCol = 0;
/* set the list view style */
ListView_SetExtendedListViewStyle(hpd->hWndDevList,
LVS_EX_FULLROWSELECT);
/* set the list view image list */
if (hpd->ClassImageListData.ImageList != NULL)
{
ListView_SetImageList(hpd->hWndDevList,
hpd->ClassImageListData.ImageList,
LVSIL_SMALL);
}
GetClientRect(hpd->hWndDevList,
&rcClient);
/* add the list view columns */
lvc.mask = LVCF_TEXT | LVCF_WIDTH;
lvc.fmt = LVCFMT_LEFT;
lvc.pszText = szColName;
if (LoadString(hDllInstance,
IDS_NAME,
szColName,
sizeof(szColName) / sizeof(szColName[0])))
{
lvc.cx = rcClient.right - CX_TYPECOLUMN_WIDTH -
GetSystemMetrics(SM_CXVSCROLL);
ListView_InsertColumn(hpd->hWndDevList,
iCol++,
&lvc);
}
if (LoadString(hDllInstance,
IDS_TYPE,
szColName,
sizeof(szColName) / sizeof(szColName[0])))
{
lvc.cx = CX_TYPECOLUMN_WIDTH;
ListView_InsertColumn(hpd->hWndDevList,
iCol++,
&lvc);
}
}
static VOID
UpdateControlStates(IN PHARDWARE_PAGE_DATA hpd)
{
PHWDEVINFO HwDevInfo;
HwDevInfo = (PHWDEVINFO)ListViewGetSelectedItemData(hpd->hWndDevList);
if (HwDevInfo != NULL)
{
/* FIXME - update static controls and enable buttons */
}
else
{
/* FIXME - clear static controls and disable buttons */
}
}
static VOID
FillDevicesList(IN PHARDWARE_PAGE_DATA hpd)
{
PHWCLASSDEVINFO DevInfo, LastDevInfo;
SP_DEVINFO_DATA DevInfoData;
WCHAR szBuffer[255];
INT ItemCount = 0;
DevInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
DevInfo = hpd->ClassDevInfo;
LastDevInfo = DevInfo + hpd->NumberOfGuids;
while (DevInfo != LastDevInfo)
{
INT ImageIndex = -1;
DevInfo->hDevInfo = SetupDiGetClassDevs(&DevInfo->Guid,
NULL,
hpd->hWnd,
DIGCF_PRESENT);
if (DevInfo->hDevInfo != INVALID_HANDLE_VALUE)
{
LVITEM li;
DWORD MemberIndex = 0;
SetupDiGetClassImageIndex(&hpd->ClassImageListData,
&DevInfo->Guid,
&ImageIndex);
while (SetupDiEnumDeviceInfo(DevInfo->hDevInfo,
MemberIndex++,
&DevInfoData))
{
DWORD RegDataType;
INT iItem;
if (DevInfo->HwDevInfo != NULL)
{
PHWDEVINFO HwNewDevInfo = HeapReAlloc(GetProcessHeap(),
0,
DevInfo->HwDevInfo,
(DevInfo->ItemCount + 1) *
sizeof(HWDEVINFO));
if (HwNewDevInfo != NULL)
{
DevInfo->HwDevInfo = HwNewDevInfo;
DevInfo->HwDevInfo[DevInfo->ItemCount].ClassDevInfo = DevInfo;
DevInfo->HwDevInfo[DevInfo->ItemCount++].DevInfoData = DevInfoData;
}
else
{
DPRINT1("Unable to allocate memory for %d SP_DEVINFO_DATA structures!\n",
DevInfo->ItemCount + 1);
break;
}
}
else
{
DevInfo->HwDevInfo = HeapAlloc(GetProcessHeap(),
0,
sizeof(HWDEVINFO));
if (DevInfo->HwDevInfo != NULL)
{
DevInfo->HwDevInfo[DevInfo->ItemCount].ClassDevInfo = DevInfo;
DevInfo->HwDevInfo[DevInfo->ItemCount++].DevInfoData = DevInfoData;
}
else
{
DPRINT1("Unable to allocate memory for a SP_DEVINFO_DATA structures!\n");
break;
}
}
if ((SetupDiGetDeviceRegistryProperty(DevInfo->hDevInfo,
&DevInfoData,
SPDRP_FRIENDLYNAME,
&RegDataType,
(PBYTE)szBuffer,
sizeof(szBuffer),
NULL) ||
SetupDiGetDeviceRegistryProperty(DevInfo->hDevInfo,
&DevInfoData,
SPDRP_DEVICEDESC,
&RegDataType,
(PBYTE)szBuffer,
sizeof(szBuffer),
NULL)) &&
RegDataType == REG_SZ)
{
/* FIXME - check string for NULL termination! */
li.mask = LVIF_PARAM | LVIF_STATE | LVIF_TEXT | LVIF_IMAGE;
li.iItem = ItemCount;
li.iSubItem = 0;
li.state = (ItemCount == 0 ? LVIS_SELECTED : 0);
li.stateMask = LVIS_SELECTED;
li.pszText = szBuffer;
li.iImage = ImageIndex;
li.lParam = (LPARAM)&DevInfo->HwDevInfo[DevInfo->ItemCount - 1];
iItem = ListView_InsertItem(hpd->hWndDevList,
&li);
if (iItem != -1)
{
ItemCount++;
if (SetupDiGetClassDescription(&DevInfo->Guid,
szBuffer,
sizeof(szBuffer) / sizeof(szBuffer[0]),
NULL))
{
li.mask = LVIF_TEXT;
li.iItem = iItem;
li.iSubItem = 1;
ListView_SetItem(hpd->hWndDevList,
&li);
}
}
}
}
}
DevInfo++;
}
/* update the controls */
UpdateControlStates(hpd);
}
static LRESULT
CALLBACK
ParentSubWndProc(IN HWND hwnd,
IN UINT uMsg,
IN WPARAM wParam,
IN LPARAM lParam)
{
PHARDWARE_PAGE_DATA hpd;
hpd = (PHARDWARE_PAGE_DATA)GetProp(hwnd,
L"DevMgrSubClassInfo");
if (hpd != NULL)
{
if (uMsg == WM_SIZE)
{
/* resize the hardware page */
SetWindowPos(hpd->hWnd,
NULL,
0,
0,
LOWORD(lParam),
HIWORD(lParam),
SWP_NOZORDER);
}
/* pass the message the the old window proc */
return CallWindowProc(hpd->ParentOldWndProc,
hwnd,
uMsg,
wParam,
lParam);
}
else
{
/* this is not a good idea if the subclassed window was an ansi
window, but we failed finding out the previous window proc
so we can't use CallWindowProc. This should rarely - if ever -
happen. */
return DefWindowProc(hwnd,
uMsg,
wParam,
lParam);
}
}
static VOID
HardwareDlgResize(IN PHARDWARE_PAGE_DATA hpd,
IN INT cx,
IN INT cy)
{
HDWP dwp;
HWND hControl, hButton;
INT Width, x, y, TopBias = 0;
RECT rc, rcButton;
POINT pt = {0};
POINT ptMargin = {0};
POINT ptMarginGroup = {0};
/* use left margin of the IDC_DEVICES label as the right
margin of all controls outside the group box */
hControl = GetDlgItem(hpd->hWnd,
IDC_DEVICES);
GetWindowRect(hControl,
&rc);
MapWindowPoints(hControl,
hpd->hWnd,
&ptMargin,
1);
Width = cx - (2 * ptMargin.x);
if ((dwp = BeginDeferWindowPos(8)))
{
/* rc already has the window rect of IDC_DEVICES! */
if (!(dwp = DeferWindowPos(dwp,
hControl,
NULL,
0,
0,
Width,
rc.bottom - rc.top,
SWP_NOMOVE | SWP_NOZORDER)))
{
return;
}
/* resize the devices list view control */
GetWindowRect(hpd->hWndDevList,
&rc);
MapWindowPoints(hpd->hWndDevList,
hpd->hWnd,
&pt,
1);
if (hpd->DisplayMode == HWPD_LARGELIST)
{
/* increase the size of the list view control by 2/3 */
TopBias = ((rc.bottom - rc.top) * 2) / 3;
}
y = pt.y + TopBias + rc.bottom - rc.top + ptMargin.y;
if (!(dwp = DeferWindowPos(dwp,
hpd->hWndDevList,
NULL,
0,
0,
Width,
rc.bottom - rc.top + TopBias,
SWP_NOMOVE | SWP_NOZORDER)))
{
return;
}
/* resize the group box control */
hControl = GetDlgItem(hpd->hWnd,
IDC_PROPERTIESGROUP);
GetWindowRect(hControl,
&rc);
if (!(dwp = DeferWindowPos(dwp,
hControl,
NULL,
ptMargin.x,
y,
Width,
cy - y - ptMargin.y,
SWP_NOZORDER)))
{
return;
}
/* use left margin of the IDC_MANUFACTURER label as the right
margin of all controls inside the group box */
hControl = GetDlgItem(hpd->hWnd,
IDC_MANUFACTURER);
GetWindowRect(hControl,
&rc);
MapWindowPoints(hControl,
hpd->hWnd,
&ptMarginGroup,
1);
ptMarginGroup.y = ptMargin.y * 2;
Width = cx - (2 * ptMarginGroup.x);
y += ptMarginGroup.y;
if (!(dwp = DeferWindowPos(dwp,
hControl,
NULL,
ptMarginGroup.x,
y,
Width,
rc.bottom - rc.top,
SWP_NOZORDER)))
{
return;
}
y += rc.bottom - rc.top + ptMargin.y;
/* resize the IDC_LOCATION label */
hControl = GetDlgItem(hpd->hWnd,
IDC_LOCATION);
GetWindowRect(hControl,
&rc);
if (!(dwp = DeferWindowPos(dwp,
hControl,
NULL,
ptMarginGroup.x,
y,
Width,
rc.bottom - rc.top,
SWP_NOZORDER)))
{
return;
}
y += rc.bottom - rc.top + ptMargin.y;
/* measure the size of the buttons */
hButton = GetDlgItem(hpd->hWnd,
IDC_PROPERTIES);
GetWindowRect(hButton,
&rcButton);
/* resize the IDC_STATUS label */
hControl = GetDlgItem(hpd->hWnd,
IDC_STATUS);
GetWindowRect(hControl,
&rc);
if (!(dwp = DeferWindowPos(dwp,
hControl,
NULL,
ptMarginGroup.x,
y,
Width,
cy - y - (3 * ptMargin.y) -
(rcButton.bottom - rcButton.top),
SWP_NOZORDER)))
{
return;
}
/* move the IDC_PROPERTIES button */
y = cy - (2 * ptMargin.y) - (rcButton.bottom - rcButton.top);
x = cx - ptMarginGroup.x - (rcButton.right - rcButton.left);
if (!(dwp = DeferWindowPos(dwp,
hButton,
NULL,
x,
y,
0,
0,
SWP_NOSIZE | SWP_NOZORDER)))
{
return;
}
/* move the IDC_TROUBLESHOOT button */
hButton = GetDlgItem(hpd->hWnd,
IDC_TROUBLESHOOT);
GetWindowRect(hButton,
&rcButton);
x -= ptMargin.x + (rcButton.right - rcButton.left);
if (!(dwp = DeferWindowPos(dwp,
hButton,
NULL,
x,
y,
0,
0,
SWP_NOSIZE | SWP_NOZORDER)))
{
return;
}
EndDeferWindowPos(dwp);
}
}
static INT_PTR
CALLBACK
HardwareDlgProc(IN HWND hwndDlg,
IN UINT uMsg,
IN WPARAM wParam,
IN LPARAM lParam)
{
PHARDWARE_PAGE_DATA hpd;
hpd = (PHARDWARE_PAGE_DATA)GetWindowLongPtr(hwndDlg,
DWL_USER);
if (hpd != NULL || uMsg == WM_INITDIALOG)
{
switch (uMsg)
{
case WM_NOTIFY:
{
NMHDR *pnmh = (NMHDR*)lParam;
if (pnmh->hwndFrom == hpd->hWndDevList)
{
switch (pnmh->code)
{
case LVN_ITEMCHANGED:
{
LPNMLISTVIEW pnmv = (LPNMLISTVIEW)lParam;
if ((pnmv->uChanged & LVIF_STATE) &&
((pnmv->uOldState & (LVIS_FOCUSED | LVIS_SELECTED)) ||
(pnmv->uNewState & (LVIS_FOCUSED | LVIS_SELECTED))))
{
UpdateControlStates(hpd);
}
break;
}
}
}
break;
}
case WM_SIZE:
HardwareDlgResize(hpd,
(INT)LOWORD(lParam),
(INT)HIWORD(lParam));
break;
case WM_INITDIALOG:
{
hpd = (PHARDWARE_PAGE_DATA)lParam;
if (hpd != NULL)
{
HWND hWndParent;
hpd->hWnd = hwndDlg;
SetWindowLongPtr(hwndDlg,
DWL_USER,
(DWORD_PTR)hpd);
hpd->ClassImageListData.cbSize = sizeof(SP_CLASSIMAGELIST_DATA);
SetupDiGetClassImageList(&hpd->ClassImageListData);
hpd->hWndDevList = GetDlgItem(hwndDlg,
IDC_LV_DEVICES);
/* subclass the parent window */
hWndParent = GetAncestor(hwndDlg,
GA_PARENT);
if (hWndParent != NULL)
{
RECT rcClient;
if (GetClientRect(hWndParent,
&rcClient) &&
SetWindowPos(hwndDlg,
NULL,
0,
0,
rcClient.right,
rcClient.bottom,
SWP_NOZORDER))
{
/* subclass the parent window. This is not safe
if the parent window belongs to another thread! */
hpd->ParentOldWndProc = (WNDPROC)SetWindowLongPtr(hWndParent,
GWLP_WNDPROC,
(LONG_PTR)ParentSubWndProc);
if (hpd->ParentOldWndProc != NULL &&
SetProp(hWndParent,
L"DevMgrSubClassInfo",
(HANDLE)hpd))
{
hpd->hWndParent = hWndParent;
}
}
}
/* initialize the devices list view control */
InitializeDevicesList(hpd);
/* fill the devices list view control */
FillDevicesList(hpd);
}
break;
}
case WM_DESTROY:
{
UINT i;
/* free the device info set handles */
for (i = 0;
i < hpd->NumberOfGuids;
i++)
{
SetupDiDestroyDeviceInfoList(hpd->ClassDevInfo[i].hDevInfo);
if (hpd->ClassDevInfo[i].HwDevInfo != NULL)
{
HeapFree(GetProcessHeap(),
0,
hpd->ClassDevInfo[i].HwDevInfo);
}
}
/* restore the old window proc of the subclassed parent window */
if (hpd->hWndParent != NULL && hpd->ParentOldWndProc != NULL)
{
SetWindowLongPtr(hpd->hWndParent,
GWLP_WNDPROC,
(LONG_PTR)hpd->ParentOldWndProc);
}
if (hpd->ClassImageListData.ImageList != NULL)
{
SetupDiDestroyClassImageList(&hpd->ClassImageListData);
}
/* free the reference to comctl32 */
FreeLibrary(hpd->hComCtl32);
hpd->hComCtl32 = NULL;
/* free the allocated resources */
HeapFree(GetProcessHeap(),
0,
hpd);
break;
}
}
}
return FALSE;
}
/***************************************************************************
* NAME EXPORTED
* DeviceCreateHardwarePageEx
*
* DESCRIPTION
* Creates a hardware page
*
* ARGUMENTS
* hWndParent: Handle to the parent window
* lpGuids: An array of guids of devices that are to be listed
* uNumberOfGuids: Numbers of guids in the Guids array
* Unknown: Unknown parameter, see NOTEs
*
* RETURN VALUE
* Returns the handle of the hardware page window that has been created or
* NULL if it failed.
*
* REVISIONS
* 13-05-2005 first working version (Sebastian Gasiorek <zebasoftis@gmail.com>)
*
* NOTE
* uUnknown seems to be some kind of flag how the entries should be displayed,
* in Win it seems to be always 0x00000001
*
* TODO
* missing: device icon in list view, Troubleshoot button, device properties,
* status description,
* devices should be visible afer PSN_SETACTIVE message
*
*/
HWND
WINAPI
DeviceCreateHardwarePageEx(IN HWND hWndParent,
IN LPGUID lpGuids,
IN UINT uNumberOfGuids,
IN HWPAGE_DISPLAYMODE DisplayMode)
{
PHARDWARE_PAGE_DATA hpd;
PINITCOMMONCONTROLS pInitCommonControls;
/* allocate the HARDWARE_PAGE_DATA structure. Make sure it is
zeroed because the initialization code assumes that in
failure cases! */
hpd = HeapAlloc(GetProcessHeap(),
HEAP_ZERO_MEMORY,
FIELD_OFFSET(HARDWARE_PAGE_DATA,
ClassDevInfo) +
(uNumberOfGuids * sizeof(HWCLASSDEVINFO)));
if (hpd != NULL)
{
HWND hWnd;
UINT i;
hpd->DisplayMode = ((DisplayMode > HWPD_MAX) ? HWPD_STANDARDLIST : DisplayMode);
/* initialize the HARDWARE_PAGE_DATA structure */
hpd->NumberOfGuids = uNumberOfGuids;
for (i = 0;
i < uNumberOfGuids;
i++)
{
hpd->ClassDevInfo[i].Guid = lpGuids[i];
}
/* load comctl32.dll dynamically */
hpd->hComCtl32 = LoadLibrary(TEXT("comctl32.dll"));
if (hpd->hComCtl32 == NULL)
{
goto Cleanup;
}
/* initialize the common controls */
pInitCommonControls = (PINITCOMMONCONTROLS)GetProcAddress(hpd->hComCtl32,
"InitCommonControls");
if (pInitCommonControls == NULL)
{
goto Cleanup;
}
pInitCommonControls();
/* create the dialog */
hWnd = CreateDialogParam(hDllInstance,
MAKEINTRESOURCE(IDD_HARDWARE),
hWndParent,
HardwareDlgProc,
(LPARAM)hpd);
if (hWnd != NULL)
{
return hWnd;
}
else
{
Cleanup:
/* oops, something went wrong... */
if (hpd->hComCtl32 != NULL)
{
FreeLibrary(hpd->hComCtl32);
}
HeapFree(GetProcessHeap(),
0,
hpd);
}
}
return NULL;
}
/***************************************************************************
* NAME EXPORTED
* DeviceCreateHardwarePage
*
* DESCRIPTION
* Creates a hardware page
*
* ARGUMENTS
* hWndParent: Handle to the parent window
* lpGuid: Guid of the device
*
* RETURN VALUE
* Returns the handle of the hardware page window that has been created or
* NULL if it failed.
*
* REVISIONS
*
* NOTE
*
*/
HWND
WINAPI
DeviceCreateHardwarePage(IN HWND hWndParent,
IN LPGUID lpGuid)
{
return DeviceCreateHardwarePageEx(hWndParent,
lpGuid,
1,
HWPD_LARGELIST);
}
BOOL
STDCALL
DllMain(IN HINSTANCE hinstDLL,
IN DWORD dwReason,
IN LPVOID lpvReserved)
{
switch (dwReason)
{
case DLL_PROCESS_ATTACH:
DisableThreadLibraryCalls(hinstDLL);
hDllInstance = hinstDLL;
break;
}
return TRUE;
}

View file

@ -3,6 +3,8 @@
#include <windows.h>
#include "resource.h"
LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
#define REACTOS_VERSION_DLL
#define REACTOS_STR_FILE_DESCRIPTION "ReactOS Device Manager\0"
#define REACTOS_STR_INTERNAL_NAME "devmgr\0"
@ -10,3 +12,6 @@
#include <reactos/version.rc>
IDI_DEVMGR ICON "resources/devmgr.ico"
#include "En.rc"
#include "Pl.rc"

View file

@ -1,4 +1,4 @@
<module name="devmgr" type="win32dll" baseaddress="${BASEADDRESS_DEVMGR}" installbase="system32" installname="devmgr.dll" allowwarnings="true">
<module name="devmgr" type="win32dll" baseaddress="${BASEADDRESS_DEVENUM}" installbase="system32" installname="devmgr.dll" allowwarnings="true">
<importlibrary definition="devmgr.def" />
<include base="devmgr">.</include>
<define name="UNICODE" />
@ -7,13 +7,14 @@
<define name="__USE_W32API" />
<define name="_WIN32_IE">0x600</define>
<define name="_WIN32_WINNT">0x501</define>
<library>ntdll</library>
<define name="WINVER">0x501</define>
<library>kernel32</library>
<library>advapi32</library>
<library>ntdll</library>
<library>setupapi</library>
<library>user32</library>
<file>devmgr.c</file>
<file>stubs.c</file>
<linkerflag>-nostartfiles</linkerflag>
<linkerflag>-nostdlib</linkerflag>
<file>devmgr.rc</file>
</module>
<file>devmgr.c</file>
<file>misc.c</file>
<file>stubs.c</file>
<pch>precomp.h</pch>
</module>

148
reactos/lib/devmgr/misc.c Normal file
View file

@ -0,0 +1,148 @@
/*
* ReactOS Device Manager Applet
* Copyright (C) 2004 - 2005 ReactOS Team
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* $Id: devmgr.c 12852 2005-01-06 13:58:04Z mf $
*
* PROJECT: ReactOS devmgr.dll
* FILE: lib/devmgr/misc.c
* PURPOSE: ReactOS Device Manager
* PROGRAMMER: Thomas Weidenmueller <w3seek@reactos.com>
* UPDATE HISTORY:
* 2005/11/24 Created
*/
#include <precomp.h>
static INT
LengthOfStrResource(IN HINSTANCE hInst,
IN UINT uID)
{
HRSRC hrSrc;
HGLOBAL hRes;
LPWSTR lpName, lpStr;
if (hInst == NULL)
{
return -1;
}
/* There are always blocks of 16 strings */
lpName = (LPWSTR)MAKEINTRESOURCE((uID >> 4) + 1);
/* Find the string table block */
if ((hrSrc = FindResourceW(hInst, lpName, (LPWSTR)RT_STRING)) &&
(hRes = LoadResource(hInst, hrSrc)) &&
(lpStr = LockResource(hRes)))
{
UINT x;
/* Find the string we're looking for */
uID &= 0xF; /* position in the block, same as % 16 */
for (x = 0; x < uID; x++)
{
lpStr += (*lpStr) + 1;
}
/* Found the string */
return (int)(*lpStr);
}
return -1;
}
static INT
AllocAndLoadString(OUT LPWSTR *lpTarget,
IN HINSTANCE hInst,
IN UINT uID)
{
INT ln;
ln = LengthOfStrResource(hInst,
uID);
if (ln++ > 0)
{
(*lpTarget) = (LPWSTR)LocalAlloc(LMEM_FIXED,
ln * sizeof(WCHAR));
if ((*lpTarget) != NULL)
{
INT Ret;
if (!(Ret = LoadStringW(hInst, uID, *lpTarget, ln)))
{
LocalFree((HLOCAL)(*lpTarget));
}
return Ret;
}
}
return 0;
}
DWORD
LoadAndFormatString(IN HINSTANCE hInstance,
IN UINT uID,
OUT LPWSTR *lpTarget,
...)
{
DWORD Ret = 0;
LPWSTR lpFormat;
va_list lArgs;
if (AllocAndLoadString(&lpFormat,
hInstance,
uID) > 0)
{
va_start(lArgs, lpTarget);
/* let's use FormatMessage to format it because it has the ability to allocate
memory automatically */
Ret = FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_STRING,
lpFormat,
0,
0,
(LPWSTR)lpTarget,
0,
&lArgs);
va_end(lArgs);
LocalFree((HLOCAL)lpFormat);
}
return Ret;
}
LPARAM
ListViewGetSelectedItemData(IN HWND hwnd)
{
int Index;
Index = ListView_GetNextItem(hwnd,
-1,
LVNI_SELECTED);
if (Index != -1)
{
LVITEM li;
li.mask = LVIF_PARAM;
li.iItem = Index;
li.iSubItem = 0;
if (ListView_GetItem(hwnd,
&li))
{
return li.lParam;
}
}
return 0;
}

View file

@ -1,8 +1,16 @@
#ifndef __DEVMGR_H
#define __DEVMGR_H
#include <windows.h>
#include <setupapi.h>
#include <cfgmgr32.h>
#include <commctrl.h>
#include "resource.h"
extern HINSTANCE hDllInstance;
ULONG DbgPrint(PCH Format,...);
WINBOOL
WINAPI
DeviceManager_ExecuteA(HWND hWndParent,
@ -150,6 +158,17 @@ DevicePropertiesExW(HWND hWndParent,
LPCWSTR lpDeviceID,
DWORD Unknown);
/* MISC.C */
DWORD
LoadAndFormatString(IN HINSTANCE hInstance,
IN UINT uID,
OUT LPWSTR *lpTarget,
...);
LPARAM
ListViewGetSelectedItemData(IN HWND hwnd);
#endif /* __DEVMGR_H */
/* EOF */

View file

@ -1,7 +1,27 @@
#ifndef __DEVMGR_RESOURCE_H
#define __DEVMGR_RESOURCE_H
#define IDI_DEVMGR 100
#define IDI_DEVMGR 100
#define IDD_HARDWARE 100
/* control IDs *must* match, some windows components
seem to use them... */
#define IDC_DEVICES 0x583
#define IDC_LV_DEVICES 0x584
#define IDC_PROPERTIESGROUP 0x585
#define IDC_MANUFACTURER 0x587
#define IDC_LOCATION 0x588
#define IDC_STATUS 0x586
#define IDC_TROUBLESHOOT 0x589
#define IDC_PROPERTIES 0x58A
#define IDS_NAME 0x100
#define IDS_TYPE 0x101
#define IDS_MANUFACTURER 0x102
#define IDS_LOCATION 0x103
#define IDS_STATUS 0x104
#endif /* __DEVMGR_RESOURCE_H */

View file

@ -15,12 +15,10 @@
* UPDATE HISTORY:
* 04-04-2004 Created
*/
#include <windows.h>
#include "devmgr.h"
#define UNIMPLEMENTED \
DbgPrint("DEVMGR: %s at %s:%d is UNIMPLEMENTED!\n",__FUNCTION__,__FILE__,__LINE__)
#include <precomp.h>
#define NDEBUG
#include <debug.h>
/***************************************************************************
* NAME EXPORTED
@ -614,74 +612,6 @@ DeviceAdvancedPropertiesW(HWND hWndParent,
}
/***************************************************************************
* NAME EXPORTED
* DeviceCreateHardwarePage
*
* DESCRIPTION
* Creates a hardware page
*
* ARGUMENTS
* hWndParent: Handle to the parent window
* lpGuid: Guid of the device
*
* RETURN VALUE
* Returns the handle of the hardware page window that has been created or
* NULL if it failed.
*
* REVISIONS
*
* NOTE
*
* @unimplemented
*/
HWND
WINAPI
DeviceCreateHardwarePage(HWND hWndParent,
LPGUID lpGuid)
{
UNIMPLEMENTED;
return NULL;
}
/***************************************************************************
* NAME EXPORTED
* DeviceCreateHardwarePageEx
*
* DESCRIPTION
* Creates a hardware page
*
* ARGUMENTS
* hWndParent: Handle to the parent window
* lpGuids: An array of guids of devices that are to be listed
* uNumberOfGuids: Numbers of guids in the Guids array
* Unknown: Unknown parameter, see NOTEs
*
* RETURN VALUE
* Returns the handle of the hardware page window that has been created or
* NULL if it failed.
*
* REVISIONS
*
* NOTE
* uUnknown seems to be some kind of flag how the entries should be displayed,
* in Win it seems to be always 0x00000001
*
* @unimplemented
*/
HWND
WINAPI
DeviceCreateHardwarePageEx(HWND hWndParent,
LPGUID lpGuids,
UINT uNumberOfGuids,
UINT Unknown)
{
UNIMPLEMENTED;
return NULL;
}
/***************************************************************************
* NAME EXPORTED
* DevicePropertiesExA