| CodeGuru Home | VC++ / MFC / C++ | .NET / C# | Visual Basic | Newsletters | VB Forums | Developer.com |
|
|||||||
| Visual C++ Programming Ask questions about Windows programming with Visual C++ and help others by answering their questions. |
![]() |
|
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
details of installed devices
hi
it will be very helpful to me if anyone tells me a way to find out the details of the installed devices in a system like display adapters, network adapters, keyboard, mouse, monitor etc., through code, which in general we see in the 'device manager'. thanking u in adance |
|
#2
|
||||
|
||||
|
attached is a DDK sample project, run the enable.exe and you'll see how to enumerate the devices, or look at the code, it should point you in the right direction.
|
|
#3
|
|||
|
|||
|
hi
i downloaded the file. the exe found in it is working fine. but i do not know how to execute the source code provided. i tried it by including them in a win32 application project. but it gives so many errors in CFGMGR32.h. plz tell me what to do? |
|
#4
|
||||
|
||||
|
Quote:
But, look at the .c files, look how it uses SetupDiOpenClassRegKey(...) etc, those calls can be found in the platform SDK, via the setupapi.h, remove the CM_get_devnode_status, which is where the CFGMGR32.h (DDK header) comes into play, those calls are depreciated anyways. |
|
#5
|
|||
|
|||
|
Try QueryDosDevice. The description of it implies it only works for DOS, but it works for most NT/2000/XP device drivers too. It might not work for what you need but it might.
|
|
#6
|
|||
|
|||
|
help!!
Well i tried using ConstructDevice and GetRegisterProperty but i got an error in GetRegisterProperty on parameter 5 saying
SetupDiGetDeviceRegistryPropertyA' : cannot convert parameter 5 from 'void *' to 'unsigned char *' Help....any alternate function would also be helpful BOOL GetRegistryProperty(HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, ULONG Property, PVOID Buffer, PULONG Length) { while (!SetupDiGetDeviceRegistryProperty(DeviceInfoSet, DeviceInfoData, Property, NULL, (PVOID)*(TCHAR **)Buffer, *Length, Length )) { if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) { // // We need to change the buffer size. // if (*(LPTSTR *)Buffer) LocalFree(*(LPTSTR *)Buffer); *(LPTSTR *)Buffer = LocalAlloc(LPTR,*Length); } else { // // Unknown Failure. // if (GetLastError() != ERROR_INVALID_DATA) DisplayError(TEXT("GetDeviceRegistryProperty")); return FALSE; } } return (*(LPTSTR *)Buffer)[0]; } #define UnknownDevice TEXT("<Unknown Device>") BOOL ConstructDeviceName( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, PVOID Buffer, PULONG Length) { if (!GetRegistryProperty(DeviceInfoSet, DeviceInfoData, SPDRP_FRIENDLYNAME , Buffer, Length)) { if (!GetRegistryProperty(DeviceInfoSet, DeviceInfoData, SPDRP_DEVICEDESC , Buffer, Length)) { if (!GetRegistryProperty(DeviceInfoSet, DeviceInfoData, SPDRP_CLASS , Buffer, Length)) { if (!GetRegistryProperty(DeviceInfoSet, DeviceInfoData, SPDRP_CLASSGUID , Buffer, Length)) { *Length = (_tcslen(UnknownDevice)+1)*sizeof(TCHAR); *(LPTSTR *)Buffer = LocalAlloc(LPTR,*Length); _tcscpy(*(LPTSTR *)Buffer,UnknownDevice); } } } } return TRUE; }
__________________
Ritwik Samsi |
|
#7
|
|||
|
|||
|
Re: details of installed devices
Quote:
How can i download and attached DDk sample project,run the enable.exe. |
|
#8
|
|||
|
|||
|
Re: details of installed devices
you can find a open source library, it will save your lots of time.
__________________
codeuu,source code |
|
#9
|
|||
|
|||
|
Hi guys,
sorry I am new here - maybe my question is stupid, but i cannot find the DDK sample project. Where can I download it? |
![]() |
| Bookmarks |
|
||||||
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|