mirror of
https://github.com/reactos/reactos.git
synced 2025-06-04 17:00:31 +00:00
- fix the treeview so it displays parent and child devices
- display the device icons for each item - other bits and bats I'm too lazy to list - it still load slowly due to multiple calls to SetupDiGetClassDevs. Need to think of a better way of gathering the info. For now though, it works. svn path=/trunk/; revision=24297
This commit is contained in:
parent
4da7594216
commit
91b9b125db
8 changed files with 80 additions and 47 deletions
|
@ -2,20 +2,27 @@ IDR_MAINMENU MENU
|
||||||
BEGIN
|
BEGIN
|
||||||
POPUP "&File"
|
POPUP "&File"
|
||||||
BEGIN
|
BEGIN
|
||||||
MENUITEM "E&xit", IDC_EXIT
|
MENUITEM "E&xit", IDC_EXIT
|
||||||
END
|
END
|
||||||
POPUP "Action"
|
POPUP "Action"
|
||||||
BEGIN
|
BEGIN
|
||||||
MENUITEM "Print", IDC_PRINT, GRAYED
|
MENUITEM "Print", IDC_PRINT, GRAYED
|
||||||
MENUITEM SEPARATOR
|
MENUITEM SEPARATOR
|
||||||
MENUITEM "Properties...", IDC_PROP
|
MENUITEM "Properties...", IDC_PROP
|
||||||
MENUITEM SEPARATOR
|
MENUITEM SEPARATOR
|
||||||
MENUITEM "Help", IDC_PROGHELP, GRAYED
|
MENUITEM "Help", IDC_PROGHELP, GRAYED
|
||||||
|
END
|
||||||
|
POPUP "View"
|
||||||
|
BEGIN
|
||||||
|
MENUITEM "Devices by type", IDC_STATIC
|
||||||
|
MENUITEM "Devices by connection", IDC_STATIC, GRAYED
|
||||||
|
MENUITEM "Resources by type", IDC_STATIC, GRAYED
|
||||||
|
MENUITEM "Resources by connection", IDC_STATIC, GRAYED
|
||||||
END
|
END
|
||||||
POPUP "Help"
|
POPUP "Help"
|
||||||
BEGIN
|
BEGIN
|
||||||
MENUITEM "Help", IDC_PROGHELP
|
MENUITEM "Help", IDC_PROGHELP
|
||||||
MENUITEM "About", IDC_ABOUT
|
MENUITEM "About", IDC_ABOUT
|
||||||
END
|
END
|
||||||
END
|
END
|
||||||
|
|
||||||
|
@ -23,9 +30,9 @@ IDR_POPUP MENU
|
||||||
BEGIN
|
BEGIN
|
||||||
POPUP "popup"
|
POPUP "popup"
|
||||||
BEGIN
|
BEGIN
|
||||||
MENUITEM "Properties...", IDC_PROP, GRAYED
|
MENUITEM "Properties...", IDC_PROP, GRAYED
|
||||||
MENUITEM SEPARATOR
|
MENUITEM SEPARATOR
|
||||||
MENUITEM "Help", IDC_PROGHELP
|
MENUITEM "Help", IDC_PROGHELP
|
||||||
END
|
END
|
||||||
END
|
END
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,9 @@ WinMain(HINSTANCE hThisInstance,
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FreeConsole();
|
||||||
|
// AllocConsole();
|
||||||
|
|
||||||
if (InitMainWindowImpl())
|
if (InitMainWindowImpl())
|
||||||
{
|
{
|
||||||
hMainWnd = CreateMainWindow(lpAppName,
|
hMainWnd = CreateMainWindow(lpAppName,
|
||||||
|
|
|
@ -31,7 +31,7 @@ InsertIntoTreeView(HWND hTV,
|
||||||
tvi.iSelectedImage = DevImage;
|
tvi.iSelectedImage = DevImage;
|
||||||
|
|
||||||
tvins.item = tvi;
|
tvins.item = tvi;
|
||||||
tvins.hInsertAfter = hRoot;
|
tvins.hParent = hRoot;
|
||||||
|
|
||||||
return TreeView_InsertItem(hTV, &tvins);
|
return TreeView_InsertItem(hTV, &tvins);
|
||||||
}
|
}
|
||||||
|
@ -39,23 +39,23 @@ InsertIntoTreeView(HWND hTV,
|
||||||
|
|
||||||
static INT
|
static INT
|
||||||
EnumDeviceClasses(INT ClassIndex,
|
EnumDeviceClasses(INT ClassIndex,
|
||||||
TCHAR *DeviceClassName,
|
LPTSTR DevClassName,
|
||||||
TCHAR *DeviceClassDesc,
|
LPTSTR DevClassDesc,
|
||||||
BOOL *DevicePresent,
|
BOOL *DevPresent,
|
||||||
INT *ClassImage)
|
INT *ClassImage)
|
||||||
{
|
{
|
||||||
GUID ClassGuid;
|
GUID ClassGuid;
|
||||||
HKEY KeyClass;
|
HKEY KeyClass;
|
||||||
HDEVINFO hDevInfo;
|
|
||||||
TCHAR ClassName[MAX_CLASS_NAME_LEN];
|
TCHAR ClassName[MAX_CLASS_NAME_LEN];
|
||||||
DWORD RequiredSize = MAX_CLASS_NAME_LEN;
|
DWORD RequiredSize = MAX_CLASS_NAME_LEN;
|
||||||
UINT Ret;
|
UINT Ret;
|
||||||
|
|
||||||
*DevicePresent = FALSE;
|
*DevPresent = FALSE;
|
||||||
|
|
||||||
Ret = CM_Enumerate_Classes(ClassIndex,
|
Ret = CM_Enumerate_Classes(ClassIndex,
|
||||||
&ClassGuid,
|
&ClassGuid,
|
||||||
0);
|
0);
|
||||||
|
|
||||||
if (Ret != CR_SUCCESS)
|
if (Ret != CR_SUCCESS)
|
||||||
{
|
{
|
||||||
/* all classes enumerated */
|
/* all classes enumerated */
|
||||||
|
@ -73,11 +73,11 @@ EnumDeviceClasses(INT ClassIndex,
|
||||||
RequiredSize,
|
RequiredSize,
|
||||||
&RequiredSize))
|
&RequiredSize))
|
||||||
{
|
{
|
||||||
lstrcpy(DeviceClassName, ClassName);
|
lstrcpy(DevClassName, ClassName);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
*DeviceClassName = _T('\0');
|
*DevClassName = _T('\0');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!SetupDiGetClassImageIndex(&ImageListData,
|
if (!SetupDiGetClassImageIndex(&ImageListData,
|
||||||
|
@ -88,13 +88,14 @@ EnumDeviceClasses(INT ClassIndex,
|
||||||
*ClassImage = 41;
|
*ClassImage = 41;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FIXME: why are we calling this here? */
|
/* FIXME: do we need this?
|
||||||
hDevInfo = SetupDiGetClassDevs(&ClassGuid,
|
hDevInfo = SetupDiGetClassDevs(&ClassGuid,
|
||||||
0,
|
0,
|
||||||
NULL,
|
NULL,
|
||||||
DIGCF_PRESENT);
|
DIGCF_PRESENT);
|
||||||
if (hDevInfo == INVALID_HANDLE_VALUE)
|
if (hDevInfo == INVALID_HANDLE_VALUE)
|
||||||
return -2;
|
return 0;
|
||||||
|
*/
|
||||||
|
|
||||||
KeyClass = SetupDiOpenClassRegKeyEx(&ClassGuid,
|
KeyClass = SetupDiOpenClassRegKeyEx(&ClassGuid,
|
||||||
MAXIMUM_ALLOWED,
|
MAXIMUM_ALLOWED,
|
||||||
|
@ -103,14 +104,15 @@ EnumDeviceClasses(INT ClassIndex,
|
||||||
0);
|
0);
|
||||||
if (KeyClass != INVALID_HANDLE_VALUE)
|
if (KeyClass != INVALID_HANDLE_VALUE)
|
||||||
{
|
{
|
||||||
|
|
||||||
DWORD dwSize = MAX_CLASS_NAME_LEN;
|
DWORD dwSize = MAX_CLASS_NAME_LEN;
|
||||||
|
|
||||||
if (RegQueryValue(KeyClass,
|
if (RegQueryValue(KeyClass,
|
||||||
NULL,
|
NULL,
|
||||||
DeviceClassDesc,
|
DevClassDesc,
|
||||||
&dwSize) != ERROR_SUCCESS)
|
&dwSize) != ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
*DeviceClassDesc = _T('\0');
|
*DevClassDesc = _T('\0');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -118,10 +120,10 @@ EnumDeviceClasses(INT ClassIndex,
|
||||||
return -3;
|
return -3;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FIXME: Can we call this earlier, or see above? */
|
/* FIXME: see above?
|
||||||
SetupDiDestroyDeviceInfoList(hDevInfo);
|
SetupDiDestroyDeviceInfoList(hDevInfo); */
|
||||||
|
|
||||||
*DevicePresent = TRUE;
|
*DevPresent = TRUE;
|
||||||
|
|
||||||
RegCloseKey(KeyClass);
|
RegCloseKey(KeyClass);
|
||||||
|
|
||||||
|
@ -143,16 +145,16 @@ EnumDevices(INT index,
|
||||||
*DeviceName = _T('\0');
|
*DeviceName = _T('\0');
|
||||||
|
|
||||||
bRet = SetupDiClassGuidsFromName(DeviceClassName,
|
bRet = SetupDiClassGuidsFromName(DeviceClassName,
|
||||||
NULL,
|
NULL,
|
||||||
RequiredSize,
|
RequiredSize,
|
||||||
&RequiredSize);
|
&RequiredSize);
|
||||||
if (RequiredSize == 0)
|
if (RequiredSize == 0)
|
||||||
return -2;
|
return -2;
|
||||||
|
|
||||||
if (!bRet)
|
if (!bRet)
|
||||||
{
|
{
|
||||||
guids = HeapAlloc(GetProcessHeap(),
|
guids = HeapAlloc(GetProcessHeap(),
|
||||||
0,
|
0,
|
||||||
RequiredSize * sizeof(GUID));
|
RequiredSize * sizeof(GUID));
|
||||||
if (guids == NULL)
|
if (guids == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -170,12 +172,13 @@ EnumDevices(INT index,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TimerInfo(_T("IN"));
|
||||||
/* get device info set for our device class */
|
/* get device info set for our device class */
|
||||||
hDevInfo = SetupDiGetClassDevs(guids,
|
hDevInfo = SetupDiGetClassDevs(guids,
|
||||||
0,
|
0,
|
||||||
NULL,
|
NULL,
|
||||||
DIGCF_PRESENT);
|
DIGCF_PRESENT);
|
||||||
|
//TimerInfo(_T("OUT"));
|
||||||
HeapFree(GetProcessHeap(), 0, guids);
|
HeapFree(GetProcessHeap(), 0, guids);
|
||||||
if(hDevInfo == INVALID_HANDLE_VALUE)
|
if(hDevInfo == INVALID_HANDLE_VALUE)
|
||||||
{
|
{
|
||||||
|
@ -322,7 +325,6 @@ InitTreeView(PMAIN_WND_INFO Info)
|
||||||
TCHAR ComputerName[MAX_PATH];
|
TCHAR ComputerName[MAX_PATH];
|
||||||
DWORD dwSize = MAX_PATH;
|
DWORD dwSize = MAX_PATH;
|
||||||
INT RootImage;
|
INT RootImage;
|
||||||
//COLORREF Mask = RGB(255, 0, 128);
|
|
||||||
|
|
||||||
TreeView_DeleteAllItems(Info->hTreeView);
|
TreeView_DeleteAllItems(Info->hTreeView);
|
||||||
|
|
||||||
|
@ -337,8 +339,10 @@ InitTreeView(PMAIN_WND_INFO Info)
|
||||||
hComp,
|
hComp,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
|
DeleteObject(hComp);
|
||||||
|
|
||||||
TreeView_SetImageList(Info->hTreeView,
|
TreeView_SetImageList(Info->hTreeView,
|
||||||
&ImageListData.ImageList,
|
ImageListData.ImageList,
|
||||||
TVSIL_NORMAL);
|
TVSIL_NORMAL);
|
||||||
|
|
||||||
if (!GetComputerName(ComputerName,
|
if (!GetComputerName(ComputerName,
|
||||||
|
@ -349,6 +353,7 @@ InitTreeView(PMAIN_WND_INFO Info)
|
||||||
|
|
||||||
RootImage = ImageList_GetImageCount(ImageListData.ImageList) - 1;
|
RootImage = ImageList_GetImageCount(ImageListData.ImageList) - 1;
|
||||||
|
|
||||||
|
/* insert the root item into the tree */
|
||||||
hRoot = InsertIntoTreeView(Info->hTreeView,
|
hRoot = InsertIntoTreeView(Info->hTreeView,
|
||||||
NULL,
|
NULL,
|
||||||
ComputerName,
|
ComputerName,
|
||||||
|
|
|
@ -248,23 +248,30 @@ MainWndCommand(PMAIN_WND_INFO Info,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IDC_PROGHELP:
|
case IDC_PROGHELP:
|
||||||
|
{
|
||||||
DisplayString(_T("Help is not yet implemented\n"));
|
DisplayString(_T("Help is not yet implemented\n"));
|
||||||
SetFocus(Info->hTreeView);
|
SetFocus(Info->hTreeView);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IDC_EXIT:
|
case IDC_EXIT:
|
||||||
|
{
|
||||||
PostMessage(Info->hMainWnd,
|
PostMessage(Info->hMainWnd,
|
||||||
WM_CLOSE,
|
WM_CLOSE,
|
||||||
0,
|
0,
|
||||||
0);
|
0);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IDC_ABOUT:
|
case IDC_ABOUT:
|
||||||
|
{
|
||||||
DialogBox(hInstance,
|
DialogBox(hInstance,
|
||||||
MAKEINTRESOURCE(IDD_ABOUTBOX),
|
MAKEINTRESOURCE(IDD_ABOUTBOX),
|
||||||
Info->hMainWnd,
|
Info->hMainWnd,
|
||||||
(DLGPROC)AboutDialogProc);
|
(DLGPROC)AboutDialogProc);
|
||||||
|
|
||||||
SetFocus(Info->hTreeView);
|
SetFocus(Info->hTreeView);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
processorArchitecture="x86"
|
processorArchitecture="x86"
|
||||||
version="1.0.0.0"
|
version="1.0.0.0"
|
||||||
type="win32"/>
|
type="win32"/>
|
||||||
<description>ReactOS Service Manager</description>
|
<description>ReactOS Device Manager</description>
|
||||||
<dependency>
|
<dependency>
|
||||||
<dependentAssembly>
|
<dependentAssembly>
|
||||||
<assemblyIdentity
|
<assemblyIdentity
|
||||||
|
|
|
@ -259,3 +259,20 @@ VOID DisplayString(PTCHAR Msg)
|
||||||
MessageBox(NULL, Msg, _T("Note!"), MB_ICONEXCLAMATION|MB_OK);
|
MessageBox(NULL, Msg, _T("Note!"), MB_ICONEXCLAMATION|MB_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
VOID TimerInfo(LPTSTR text)
|
||||||
|
{
|
||||||
|
static HANDLE hOut = NULL;
|
||||||
|
DWORD Count;
|
||||||
|
TCHAR buf[256];
|
||||||
|
static DWORD start = 0;
|
||||||
|
|
||||||
|
if (!start) start = GetTickCount();
|
||||||
|
|
||||||
|
if (!hOut) hOut = GetStdHandle(STD_ERROR_HANDLE);
|
||||||
|
|
||||||
|
if (text) _sntprintf(buf, 256, _T("%s\ttime : %d\n"), text, GetTickCount() - start);
|
||||||
|
else _sntprintf(buf, 256, _T("time : %d\n"), GetTickCount() - start);
|
||||||
|
|
||||||
|
WriteConsole(hOut, buf, lstrlen(buf)+1, &Count, NULL);
|
||||||
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
#ifndef __DEVMGMT_PRECOMP_H
|
#ifndef __DEVMGMT_PRECOMP_H
|
||||||
#define __DEVMGMT_PRECOMP_H
|
#define __DEVMGMT_PRECOMP_H
|
||||||
|
|
||||||
//#define WIN32_LEAN_AND_MEAN
|
#define WIN32_LEAN_AND_MEAN
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <windowsx.h> /* GET_X/Y_LPARAM */
|
#include <windowsx.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <tchar.h>
|
#include <tchar.h>
|
||||||
#include <setupapi.h>
|
#include <setupapi.h>
|
||||||
|
@ -15,15 +15,8 @@
|
||||||
#pragma warning(disable : 4100)
|
#pragma warning(disable : 4100)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef SB_SIMPLEID
|
|
||||||
#define SB_SIMPLEID 0xFF
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define NO_ITEM_SELECTED -1
|
|
||||||
#define MAX_KEY_LENGTH 256
|
|
||||||
#define MAX_DEV_LEN 1000
|
#define MAX_DEV_LEN 1000
|
||||||
|
|
||||||
|
|
||||||
typedef struct _MAIN_WND_INFO
|
typedef struct _MAIN_WND_INFO
|
||||||
{
|
{
|
||||||
HWND hMainWnd;
|
HWND hMainWnd;
|
||||||
|
@ -89,14 +82,16 @@ INT GetTextFromEdit(OUT LPTSTR lpString,
|
||||||
IN HWND hDlg,
|
IN HWND hDlg,
|
||||||
IN UINT Res);
|
IN UINT Res);
|
||||||
|
|
||||||
VOID GetError(VOID);
|
|
||||||
|
|
||||||
VOID DisplayString(PTCHAR);
|
|
||||||
|
|
||||||
HIMAGELIST InitImageList(UINT NumButtons,
|
HIMAGELIST InitImageList(UINT NumButtons,
|
||||||
UINT StartResource,
|
UINT StartResource,
|
||||||
UINT Width,
|
UINT Width,
|
||||||
UINT Height);
|
UINT Height);
|
||||||
|
|
||||||
|
VOID GetError(VOID);
|
||||||
|
|
||||||
|
VOID DisplayString(PTCHAR);
|
||||||
|
|
||||||
|
VOID TimerInfo(LPTSTR);
|
||||||
|
|
||||||
|
|
||||||
#endif /* __DEVMGMT_PRECOMP_H */
|
#endif /* __DEVMGMT_PRECOMP_H */
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
#define IDC_STATIC -1
|
#define IDC_STATIC -1
|
||||||
|
|
||||||
|
|
||||||
#define IDI_MAIN_ICON 50
|
#define IDI_MAIN_ICON 50
|
||||||
#define IDB_ROOT_IMAGE 51
|
#define IDB_ROOT_IMAGE 51
|
||||||
|
|
Loading…
Reference in a new issue