CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9
  1. #1
    Join Date
    Mar 2003
    Location
    Pondicherry, India
    Posts
    31

    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. #2
    Join Date
    Sep 2002
    Location
    Maryland - Fear The Turtle!
    Posts
    7,537
    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. #3
    Join Date
    Mar 2003
    Location
    Pondicherry, India
    Posts
    31
    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. #4
    Join Date
    Sep 2002
    Location
    Maryland - Fear The Turtle!
    Posts
    7,537
    Originally posted by shobaradha
    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?
    That is because it comes from the DDK (Driver Device Kit) which I'm sure you don't have installed. You have to take what is given and translate it into a VC++ IDE project, that was what I meant by getting you a start in the right direction.

    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. #5
    Join Date
    May 1999
    Location
    Southern California
    Posts
    12,266
    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.
    "Signature":
    My web site is Simple Samples.
    C# Corner Editor

  6. #6
    Join Date
    Aug 2003
    Posts
    107

    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. #7
    Join Date
    Jul 2008
    Posts
    107

    Re: details of installed devices

    Quote Originally Posted by Mick
    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.
    Hi all

    How can i download and attached DDk sample project,run the enable.exe.

  8. #8
    Join Date
    Dec 2007
    Posts
    13

    Re: details of installed devices

    you can find a open source library, it will save your lots of time.

  9. #9
    Join Date
    Mar 2009
    Posts
    1

    Red face Re: details of installed devices

    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?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured