Link to home
Start Free TrialLog in
Avatar of bpl5000
bpl5000

asked on

How to get display adapter info using VB6

I want to run a VB6 program that determines the current display adapter (video card).  For example, if I go into Device Manager on my PC and look at my display adapter, it is called an NVIDIA GeForce GT 330.  How can I retrieve this info with VB6?
ASKER CERTIFIED SOLUTION
Avatar of Martin Liss
Martin Liss
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of bpl5000
bpl5000

ASKER

I took out just the part that I needed, which would be the declarations and this code...

    Dim DD As DISPLAY_DEVICE, DevM As DEVMODE
    DD.cb = Len(DD)
    If EnumDisplayDevices(ByVal 0&, 0, DD, ByVal 0&) Then
        'and show it
        MsgBox Left$(DD.DeviceString, InStr(1, DD.DeviceString, Chr$(0)) - 1)
    Else
        MsgBox "failed"
    End If

Open in new window


This did work on my PC, but on the PC with the display adapter I'm looking to find, it fails saying "Path not found".

Any ideas?
Avatar of bpl5000

ASKER

Ok, this seems to work...

Sub Main()

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from Win32_DisplayConfiguration")

For Each objItem In colItems
     MsgBox "Device Name: " & objItem.DeviceName
Next

End Sub

Open in new window

Avatar of bpl5000

ASKER

I tried to give MartinLiss all the points and mark my last post as the best solution, but that didn't seem to work.