CodeGuru Forums -
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic Newsletters VB Forums Developer.com


Newest CodeGuru.com Articles:

  • Deploying Windows Server 2008 with System Center
  • Remote Desktop Protocol Performance Improvements in Windows Server 2008 R2 and Windows 7
  • The Microsoft Dynamics CRM Security Model
  • SQL Server Modeling Services with Microsoft Visual Studio 2010 Beta 2

  • Search CodeGuru:
     



    Go Back   CodeGuru Forums > Visual C++ & C++ Programming > Visual C++ Programming
    FAQ Members List Calendar Search Today's Posts Mark Forums Read

    Visual C++ Programming Ask questions about Windows programming with Visual C++ and help others by answering their questions.

    Reply
     
    Thread Tools Search this Thread Rate Thread Display Modes
      #1    
    Old September 30th, 2003, 02:18 AM
    shobaradha shobaradha is offline
    Member
     
    Join Date: Mar 2003
    Location: Pondicherry, India
    Posts: 31
    shobaradha is an unknown quantity at this point (<10)
    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
    Reply With Quote
      #2    
    Old September 30th, 2003, 02:39 AM
    Mick's Avatar
    Mick Mick is offline
    Banned
     
    Join Date: Sep 2002
    Location: Maryland - Fear The Turtle!
    Posts: 7,537
    Mick is a splendid one to behold (750+) Mick is a splendid one to behold (750+) Mick is a splendid one to behold (750+) Mick is a splendid one to behold (750+) Mick is a splendid one to behold (750+) Mick is a splendid one to behold (750+) Mick is a splendid one to behold (750+) Mick is a splendid one to behold (750+)
    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.
    Reply With Quote
      #3    
    Old September 30th, 2003, 06:04 AM
    shobaradha shobaradha is offline
    Member
     
    Join Date: Mar 2003
    Location: Pondicherry, India
    Posts: 31
    shobaradha is an unknown quantity at this point (<10)
    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?
    Reply With Quote
      #4    
    Old September 30th, 2003, 10:40 AM
    Mick's Avatar
    Mick Mick is offline
    Banned
     
    Join Date: Sep 2002
    Location: Maryland - Fear The Turtle!
    Posts: 7,537
    Mick is a splendid one to behold (750+) Mick is a splendid one to behold (750+) Mick is a splendid one to behold (750+) Mick is a splendid one to behold (750+) Mick is a splendid one to behold (750+) Mick is a splendid one to behold (750+) Mick is a splendid one to behold (750+) Mick is a splendid one to behold (750+)
    Quote:
    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.
    Reply With Quote
      #5    
    Old October 2nd, 2003, 04:09 AM
    Sam Hobbs Sam Hobbs is offline
    Elite Member
    Power Poster
     
    Join Date: May 1999
    Location: Southern California
    Posts: 12,261
    Sam Hobbs has a spectacular aura about (125+) Sam Hobbs has a spectacular aura about (125+)
    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.
    Reply With Quote
      #6    
    Old December 11th, 2003, 07:04 AM
    RookieRitwik RookieRitwik is offline
    Member
     
    Join Date: Aug 2003
    Posts: 107
    RookieRitwik is an unknown quantity at this point (<10)
    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
    Reply With Quote
      #7    
    Old August 9th, 2008, 02:06 AM
    vcprog vcprog is offline
    Member
     
    Join Date: Jul 2008
    Posts: 107
    vcprog is on a distinguished road (30+)
    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.
    Reply With Quote
      #8    
    Old August 9th, 2008, 02:40 AM
    yulin11 yulin11 is offline
    Junior Member
     
    Join Date: Dec 2007
    Posts: 13
    yulin11 is an unknown quantity at this point (<10)
    Re: details of installed devices

    you can find a open source library, it will save your lots of time.
    __________________
    codeuu,source code
    Reply With Quote
      #9    
    Old March 17th, 2009, 05:08 AM
    daAnde daAnde is offline
    Junior Member
     
    Join Date: Mar 2009
    Posts: 1
    daAnde is an unknown quantity at this point (<10)
    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?
    Reply With Quote
    Reply

    Bookmarks
    Go Back   CodeGuru Forums > Visual C++ & C++ Programming > Visual C++ Programming


    Thread Tools Search this Thread
    Search this Thread:

    Advanced Search
    Display Modes Rate This Thread
    Rate This Thread:

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is On
    HTML code is Off
    Forum Jump


    All times are GMT -5. The time now is 03:29 PM.



    Acceptable Use Policy


    The Network for Technology Professionals

    Search:

    About Internet.com

    Legal Notices, Licensing, Permissions, Privacy Policy.
    Advertise | Newsletters | E-mail Offers


    Powered by vBulletin® Version 3.7.3
    Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.