Results 1 to 13 of 13

Thread: Scan FOR Hardware

  1. #1

    Thread Starter
    Fanatic Member coolcurrent4u's Avatar
    Join Date
    Apr 2008
    Location
    *****
    Posts
    993

    Question Scan FOR Hardware

    Am trying to write a program that will scan any windows xp installed computers for hardware names and manufacturers

    Any help how to go about that?

  2. #2
    Lively Member
    Join Date
    Dec 2008
    Location
    Hobart, Tasmania
    Posts
    104

    Re: Scan FOR Hardware

    Hi.

    I'd use code to access the windows registry and pull the info from there.

    Most of the details on hardware is stored in the following location:

    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum
    For example,
    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\PCI\VEN_8086&DEV_100E&SUBSYS_02671014&REV_02\4&2529 6d99&0&58F0
    , contains the following data:

    Windows Registry Editor Version 5.00

    [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\PCI\VEN_8086&DEV_100E&SUBSYS_02671014&REV_02\4&2529 6d99&0&58F0]
    "DeviceDesc"="Intel(R) PRO/1000 MT Network Connection"
    "LocationInformation"="PCI bus 2, device 11, function 0"
    "Capabilities"=dword:00000000
    "HardwareID"=hex(7):50,00,43,00,49,00,5c,00,56,00,45,00,4e,00,5f,00,38,00,30,\
    00,38,00,36,00,26,00,44,00,45,00,56,00,5f,00,31,00,30,00,30,00,45,00,26,00,\
    53,00,55,00,42,00,53,00,59,00,53,00,5f,00,30,00,32,00,36,00,37,00,31,00,30,\
    00,31,00,34,00,26,00,52,00,45,00,56,00,5f,00,30,00,32,00,00,00,50,00,43,00,\
    49,00,5c,00,56,00,45,00,4e,00,5f,00,38,00,30,00,38,00,36,00,26,00,44,00,45,\
    00,56,00,5f,00,31,00,30,00,30,00,45,00,26,00,53,00,55,00,42,00,53,00,59,00,\
    53,00,5f,00,30,00,32,00,36,00,37,00,31,00,30,00,31,00,34,00,00,00,50,00,43,\
    00,49,00,5c,00,56,00,45,00,4e,00,5f,00,38,00,30,00,38,00,36,00,26,00,44,00,\
    45,00,56,00,5f,00,31,00,30,00,30,00,45,00,26,00,43,00,43,00,5f,00,30,00,32,\
    00,30,00,30,00,30,00,30,00,00,00,50,00,43,00,49,00,5c,00,56,00,45,00,4e,00,\
    5f,00,38,00,30,00,38,00,36,00,26,00,44,00,45,00,56,00,5f,00,31,00,30,00,30,\
    00,45,00,26,00,43,00,43,00,5f,00,30,00,32,00,30,00,30,00,00,00,00,00
    "CompatibleIDs"=hex(7):50,00,43,00,49,00,5c,00,56,00,45,00,4e,00,5f,00,38,00,\
    30,00,38,00,36,00,26,00,44,00,45,00,56,00,5f,00,31,00,30,00,30,00,45,00,26,\
    00,52,00,45,00,56,00,5f,00,30,00,32,00,00,00,50,00,43,00,49,00,5c,00,56,00,\
    45,00,4e,00,5f,00,38,00,30,00,38,00,36,00,26,00,44,00,45,00,56,00,5f,00,31,\
    00,30,00,30,00,45,00,00,00,50,00,43,00,49,00,5c,00,56,00,45,00,4e,00,5f,00,\
    38,00,30,00,38,00,36,00,26,00,43,00,43,00,5f,00,30,00,32,00,30,00,30,00,30,\
    00,30,00,00,00,50,00,43,00,49,00,5c,00,56,00,45,00,4e,00,5f,00,38,00,30,00,\
    38,00,36,00,26,00,43,00,43,00,5f,00,30,00,32,00,30,00,30,00,00,00,50,00,43,\
    00,49,00,5c,00,56,00,45,00,4e,00,5f,00,38,00,30,00,38,00,36,00,00,00,50,00,\
    43,00,49,00,5c,00,43,00,43,00,5f,00,30,00,32,00,30,00,30,00,30,00,30,00,00,\
    00,50,00,43,00,49,00,5c,00,43,00,43,00,5f,00,30,00,32,00,30,00,30,00,00,00,\
    00,00
    "ClassGUID"="{4D36E972-E325-11CE-BFC1-08002BE10318}"
    "Class"="Net"
    "Driver"="{4D36E972-E325-11CE-BFC1-08002BE10318}\\0001"
    "Mfg"="Intel"
    "Service"="E1000"
    "ConfigFlags"=dword:00000000

    [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\PCI\VEN_8086&DEV_100E&SUBSYS_02671014&REV_02\4&2529 6d99&0&58F0\Device Parameters]
    "InstanceIndex"=dword:00000001

    [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\PCI\VEN_8086&DEV_100E&SUBSYS_02671014&REV_02\4&2529 6d99&0&58F0\LogConf]
    "BasicConfigVector"=hex(a):08,01,00,00,05,00,00,00,02,00,00,00,0b,00,00,00,00,\
    00,00,00,00,00,00,00,00,00,00,00,01,00,00,00,01,00,01,00,07,00,00,00,01,03,\
    01,00,00,00,00,00,00,00,02,00,01,00,00,00,00,00,10,c0,00,00,00,00,ff,ff,11,\
    c0,00,00,00,00,08,03,01,00,00,00,00,00,00,00,02,00,00,00,02,00,00,00,00,00,\
    00,00,00,00,ff,ff,ff,ff,00,00,00,00,00,81,01,00,00,00,00,00,01,00,00,00,00,\
    00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,01,01,01,00,31,00,\
    00,00,40,00,00,00,01,00,00,00,00,20,00,00,00,00,00,00,3f,20,00,00,00,00,00,\
    00,08,01,01,00,31,00,00,00,40,00,00,00,40,00,00,00,00,00,00,00,00,00,00,00,\
    ff,ff,ff,ff,00,00,00,00,00,81,01,00,00,00,00,00,01,00,00,00,02,00,00,00,00,\
    00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,02,03,00,00,00,00,00,00,00,\
    00,00,ff,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00
    "BootConfig"=hex(8):01,00,00,00,05,00,00,00,02,00,00,00,01,00,01,00,03,00,00,\
    00,03,00,00,00,00,00,10,c0,00,00,00,00,00,00,02,00,01,00,01,00,00,20,00,00,\
    00,00,00,00,40,00,00,00,02,03,00,00,0b,00,00,00,0b,00,00,00,ff,ff,ff,ff

    [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\PCI\VEN_8086&DEV_100E&SUBSYS_02671014&REV_02\4&2529 6d99&0&58F0\Control]
    "ActiveService"="E1000"
    "FilteredConfigVector"=hex(a):08,01,00,00,05,00,00,00,02,00,00,00,0b,00,00,00,\
    00,00,00,00,00,00,00,00,00,00,00,00,01,00,00,00,01,00,01,00,07,00,00,00,01,\
    03,01,00,00,00,00,00,00,00,02,00,01,00,00,00,00,00,10,c0,00,00,00,00,ff,ff,\
    11,c0,00,00,00,00,08,03,01,00,00,00,00,00,00,00,02,00,00,00,02,00,00,00,00,\
    00,00,00,00,00,ff,ff,ff,ff,00,00,00,00,00,81,01,00,00,00,00,00,01,00,00,00,\
    00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,01,01,01,00,31,\
    00,00,00,40,00,00,00,01,00,00,00,00,20,00,00,00,00,00,00,3f,20,00,00,00,00,\
    00,00,08,01,01,00,31,00,00,00,40,00,00,00,40,00,00,00,00,00,00,00,00,00,00,\
    00,ff,ff,ff,ff,00,00,00,00,00,81,01,00,00,00,00,00,01,00,00,00,02,00,00,00,\
    00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,02,03,00,00,00,00,00,00,\
    00,00,00,ff,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00
    "AllocConfig"=hex(8):01,00,00,00,05,00,00,00,02,00,00,00,00,00,00,00,05,00,00,\
    00,03,01,00,00,00,00,10,c0,00,00,00,00,00,00,02,00,81,01,00,00,01,00,00,00,\
    00,00,00,00,00,00,00,00,01,01,31,00,00,20,00,00,00,00,00,00,40,00,00,00,81,\
    01,00,00,01,00,00,00,02,00,00,00,00,00,00,00,02,03,00,00,10,00,00,00,10,00,\
    00,00,ff,ff,ff,ff
    Obviously, the item you're after would be

    "DeviceDesc"="Intel(R) PRO/1000 MT Network Connection"
    There is probably a nice neat list similar to device manager somewhere in the registry, but I havent looked.

    Another related use. You can look at the following key to check installed drives (only by drive letter though)

    HKEY_LOCAL_MACHINE\SYSTEM\MountedDevices
    You can then check that key to see if a flash disk has been plugged in or not, etc, prior to running an automated backup, for example.

    As to code to access the registry, i found it on these forums, I cant remember off hand, but shouldn't take too long to find.


    Hope this information helps

    JoshAU

  3. #3

  4. #4

    Thread Starter
    Fanatic Member coolcurrent4u's Avatar
    Join Date
    Apr 2008
    Location
    *****
    Posts
    993

    Re: Scan FOR Hardware

    Thanks joshAU

    but i don't know how to do registry thing in vb

    csn you help me out

  5. #5

  6. #6

    Thread Starter
    Fanatic Member coolcurrent4u's Avatar
    Join Date
    Apr 2008
    Location
    *****
    Posts
    993

    Re: Scan FOR Hardware

    ca iuse this to detect uninstalled driver ordevice.

    take for example.

    i will be using this softwareto detect hardware of the system,and use the information to fined the drivers.

    does windows have information of all hardware in the system

  7. #7
    Fanatic Member sessi4ml's Avatar
    Join Date
    Nov 2006
    Location
    Near San Francisco
    Posts
    958

    Re: Scan FOR Hardware

    One could try the "Detailed Computer Scan" link
    This will create a file about the system, then search the file for the detail one is looking for.

  8. #8

    Thread Starter
    Fanatic Member coolcurrent4u's Avatar
    Join Date
    Apr 2008
    Location
    *****
    Posts
    993

    Re: Scan FOR Hardware

    can you tell me how to do that or give me an exampe project

  9. #9
    Fanatic Member sessi4ml's Avatar
    Join Date
    Nov 2006
    Location
    Near San Francisco
    Posts
    958

    Re: Scan FOR Hardware

    Create a program using the VB object (Inet), Change the default browser to your new program, run 'Detailed Computer Scan' (Belarc.exe).
    Your browser, the new default, will contain the scan detail.
    Change the default browser back to normal, now you can 'INSTR' the scanned info.

    * I just use the tools I understand. Could VB scan the compter,...yes...I don't know how, and that would be a lot of code

    Although, it does sound like a cool program.

  10. #10
    Lively Member
    Join Date
    Dec 2008
    Location
    Hobart, Tasmania
    Posts
    104

    Re: Scan FOR Hardware

    as a quick and dirty way of doing it...

    you could shell out a reg query and output to a text file, then read and process that file in vb.

    If your interested, here is some code that will display the device descriptions of hardware found under:

    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\PCI.

    This key has most of the "interesting" hardware, although there is a lot more found in the key above....ie

    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum

    play around with the key by changing Text1.Text to whatever your after.

    Simply create a new project, paste the code into it, add 3x labels, 2x textboxes, 1x command button.
    make label3 large..eg 6000W x 10000+H, with all other labels, textboxes and the command button above it.
    Then run it.

    This code shells reg.exe and outputs result to text file, then extracts
    device descriptions and adds them to label 3.
    Obviously there are no doubt better ways of doing this.
    I just dont have the time to find the code to avoid having to use reg.exe in
    the first place.


    Code:
    Private Sub Form_Load()
    'program requires the existence of reg.exe in the system32 folder.
    '(Which is installed there by default under 2K, XP and I think, vista)
    'It also requires admin/system privilidges.
    'also requires a form named form1 with 3 labels, 2 text boxes and a command button.
    
    
    'this finds a lot of interesting items
    Text1.Text = """" & "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\PCI" & """"
    
    'this finds all items, inc devices not currently connected, eg old monitors, cdroms, etc
    'Text1.Text = """" & "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum" & """"
    
    Text2.Text = "DeviceDesc"
    
    Label1.Caption = "Registry Key"
    Label2.Caption = "Registry Value"
    Label3.Caption = ""
    Command1.Caption = "Get Info"
    End Sub
    
    Private Sub Command1_Click()
    Dim Textfile As String
    Dim Textfile2 As String
    Dim tmp As String
    Dim tmp2 As String
    Dim key As String
    
    key = Text1.Text
    Label3.Caption = ""
    
    'set txt file path
    Textfile = App.Path & "\Text.txt"
    Textfile2 = App.Path & "\Text2.txt"
    
    'get top level keys under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\PCI
    Shell "cmd.exe /c " & "reg query " & Text1.Text & " /s " & " > " & """" & Textfile & """"
    
    'needs a delay added here
    
    
    'open the file
    Open Textfile For Input As #1
    
        'remove the first three useless lines
        Input #1, tmp
        Input #1, tmp
        Input #1, tmp
        
        'loop through each line of the file
        Do Until EOF(1)
            Input #1, tmp
            
            If tmp <> "" Then
                'get 2nd level keys under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\PCI
                Shell "cmd.exe /c " & "reg query " & """" & Text2.Text & "\" & tmp & " /s " & " > " & """" & Textfile2 & """" & """"
    
                'open the file
                Open Textfile For Input As #2
                    'remove the first three useless lines
                    Input #1, tmp2
                    Input #1, tmp2
                    Input #1, tmp2
    
                    'loop through each line of the file
                    Do Until EOF(1)
                        Input #1, tmp2
                        If tmp2 <> "" Then
                            If Left(tmp2, 10) = "DeviceDesc" Then
                                tmp2 = Right(tmp2, Len(tmp2) - 18)
                                'Do something with it...
                                Label3.Caption = Label3.Caption & Chr(13) & tmp2
                            End If
                        End If
                    Loop
                Close #2
            End If
        Loop
        
    Close #1
    End Sub
    This was patched together and hasnt been really tested.
    I think there is an issue with the syntax of text1, to do with the " symbol.
    If you have an issue, try removing them from text1, or making sure they are both there.
    Its late so I cant fully test it ,but should give you an idea.

    joshAU
    Last edited by joshAU; May 20th, 2009 at 10:59 AM.

  11. #11

    Thread Starter
    Fanatic Member coolcurrent4u's Avatar
    Join Date
    Apr 2008
    Location
    *****
    Posts
    993

    Question Re: Scan FOR Hardware

    thanks for the response

    i'll try your examples


    i think i need a class that can recursively scan the registry.

    but what i don't know is if windows store information about uninstall ed hardware.

    i want to pull tha infor mation out , both the installed hardware and the unistalled oness

    thanks

  12. #12
    Lively Member
    Join Date
    Dec 2008
    Location
    Hobart, Tasmania
    Posts
    104

    Re: Scan FOR Hardware

    Windows does seem to store info of hardware that is no longer installed.
    eg if you run the example code you'll probably see multiple monitors listed.
    I dont know if the registry holds info on ALL hardware that has ever been installed, however.

    From memory, it makes sense that it does.
    eg. if you pull out a pci card, and then later reinstall it in the same slot, windows doesnt prompt you with the found new hardware wizard.
    If you install it in another slot, it will prompt you, as the info it holds about the hardware doesnt match whats in the registry.
    So the registry must retain some info about the old hardware.

    I had a bit of a look through the registry trying to find it last night, but found nothing conclusive, but neither was my search....

    Im sure there is a class for registry access/editing on these forums.
    It would be less clunky than shelling reg.exe.

    This is the contents of registry.bas, located, at least on my system, in

    "C:\Program Files\Microsoft Visual Studio\VB98\Wizards\PDWizard\Setup1\REGISTRY.BAS"

    and I assume its included with vb6.
    I havent gone through it all, but looks like it may be more like what your after.

    Code:
    Option Explicit
    Option Compare Text
    
    Private Const gsSLASH_BACKWARD As String = "\"
    
    ''Registry API Declarations...
    Private Declare Function RegCloseKey Lib "advapi32" (ByVal hKey As Long) As Long
    Private Declare Function RegCreateKeyEx Lib "advapi32" Alias "RegCreateKeyExA" _
        (ByVal hKey As Long, ByVal lpSubKey As String, ByVal Reserved As Long, _
        ByVal lpClass As String, ByVal dwOptions As Long, ByVal samDesired As Long, _
        ByRef lpSecurityAttributes As SECURITY_ATTRIBUTES, ByRef phkResult As Long, _
        ByRef lpdwDisposition As Long) As Long
    Private Declare Function RegDeleteKey Lib "advapi32" Alias "RegDeleteKeyA" _
        (ByVal hKey As Long, ByVal lpSubKey As String) As Long
    Private Declare Function RegOpenKeyEx Lib "advapi32" Alias "RegOpenKeyExA" _
        (ByVal hKey As Long, ByVal lpSubKey As String, ByVal ulOptions As Long, _
        ByVal samDesired As Long, ByRef phkResult As Long) As Long
    Private Declare Function RegQueryValueEx Lib "advapi32" Alias "RegQueryValueExA" _
        (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, _
        ByRef lpType As Long, ByVal lpData As String, ByRef lpcbData As Long) As Long
    Private Declare Function RegSetValueEx Lib "advapi32" Alias "RegSetValueExA" _
        (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, _
        ByVal dwType As Long, ByVal lpData As String, ByVal cbData As Long) As Long
    Private Declare Function RegEnumValue Lib "advapi32" Alias "RegEnumValueA" _
        (ByVal hKey As Long, ByVal dwIndex As Long, ByVal lpValueName As String, _
        ByRef lpcbValueName As Long, ByVal lpReserved As Long, ByRef lpType As Long, _
        ByVal lpData As String, ByRef lpcbData As Long) As Long
    Private Declare Function RegEnumKeyEx Lib "advapi32.dll" Alias "RegEnumKeyExA" _
        (ByVal hKey As Long, ByVal dwIndex As Long, ByVal lpName As String, _
        lpcbName As Long, ByVal lpReserved As Long, ByVal lpClass As Long, _
        ByVal lpcbClass As Long, lpftLastWriteTime As FileTime) As Long
    
    ''Reg Data Types...
    Private Const REG_NONE = 0                                          ' No value type
    Private Const REG_SZ = 1                                            ' Unicode nul terminated string
    Private Const REG_EXPAND_SZ = 2                                     ' Unicode nul terminated string
    Private Const REG_BINARY = 3                                        ' Free form binary
    Private Const REG_DWORD = 4                                         ' 32-bit number
    Private Const REG_DWORD_LITTLE_ENDIAN = 4                           ' 32-bit number (same as REG_DWORD)
    Private Const REG_DWORD_BIG_ENDIAN = 5                              ' 32-bit number
    Private Const REG_LINK = 6                                          ' Symbolic Link (unicode)
    Private Const REG_MULTI_SZ = 7                                      ' Multiple Unicode strings
    Private Const REG_RESOURCE_LIST = 8                                 ' Resource list in the resource map
    Private Const REG_FULL_RESOURCE_DESCRIPTOR = 9                      ' Resource list in the hardware description
    Private Const REG_RESOURCE_REQUIREMENTS_LIST = 10
    
    ''Reg Create Type Values...
    Private Const REG_OPTION_RESERVED = 0                               ' Parameter is reserved
    Private Const REG_OPTION_NON_VOLATILE = 0                           ' Key is preserved when system is rebooted
    Private Const REG_OPTION_VOLATILE = 1                               ' Key is not preserved when system is rebooted
    Private Const REG_OPTION_CREATE_LINK = 2                            ' Created key is a symbolic link
    Private Const REG_OPTION_BACKUP_RESTORE = 4                         ' open for backup or restore
    
    ''Reg Key Security Options...
    Private Const READ_CONTROL = &H20000
    Private Const KEY_QUERY_VALUE = &H1
    Private Const KEY_SET_VALUE = &H2
    Private Const KEY_CREATE_SUB_KEY = &H4
    Private Const KEY_ENUMERATE_SUB_KEYS = &H8
    Private Const KEY_NOTIFY = &H10
    Private Const KEY_CREATE_LINK = &H20
    Private Const KEY_READ = KEY_QUERY_VALUE + KEY_ENUMERATE_SUB_KEYS + KEY_NOTIFY + READ_CONTROL
    Private Const KEY_WRITE = KEY_SET_VALUE + KEY_CREATE_SUB_KEY + READ_CONTROL
    Private Const KEY_EXECUTE = KEY_READ
    Private Const KEY_ALL_ACCESS = KEY_QUERY_VALUE + KEY_SET_VALUE _
                                + KEY_CREATE_SUB_KEY + KEY_ENUMERATE_SUB_KEYS _
                                + KEY_NOTIFY + KEY_CREATE_LINK + READ_CONTROL
    
    ''Return Value...
    Private Const ERROR_SUCCESS = 0
    Private Const ERROR_ACCESS_DENIED = 5&
    Private Const ERROR_NO_MORE_ITEMS = 259&
    
    ''Hierarchy separator
    Private Const KeySeparator As String = "\"
    
    ''Registry Security Attributes TYPE...
    Private Type SECURITY_ATTRIBUTES
        nLength As Long
        lpSecurityDescriptor As Long
        bInheritHandle As Boolean
    End Type
    Private Type FileTime
        dwLowDateTime As Long
        dwHighDateTime As Long
    End Type
    
    ''Reg Key ROOT Types...
    Public Enum REGToolRootTypes
        HK_CLASSES_ROOT = &H80000000
        HK_CURRENT_USER = &H80000001
        HK_LOCAL_MACHINE = &H80000002
        HK_USERS = &H80000003
        HK_PERFORMANCE_DATA = &H80000004
        HK_CURRENT_CONFIG = &H80000005
        HK_DYN_DATA = &H80000006
    End Enum
    
    'Retrieves a key value.
    Public Function GetKeyValue(ByVal KeyRoot As REGToolRootTypes, KeyName As String, ValueName As String, ByRef ValueData As String) As Boolean
        Dim i As Long                                                   ' Loop Counter
        Dim hKey As Long                                                ' Handle To An Open Registry Key
        Dim KeyValType As Long                                          ' Data Type Of A Registry Key
        Dim sTmp As String                                              ' Tempory Storage For A Registry Key Value
        Dim sReturn As String
        Dim KeyValSize As Long                                          ' Size Of Registry Key Variable
        Dim sByte As String
    
        If ValidKeyName(KeyName) Then
            On Error GoTo LocalErr
    
            ' Open registry key under KeyRoot
            Attempt RegOpenKeyEx(KeyRoot, KeyName, 0, KEY_ALL_ACCESS, hKey)
    
            sTmp = String$(1024, 0)                                         ' Allocate Variable Space
            KeyValSize = 1024                                               ' Mark Variable Size
    
            ' Retrieve Registry Key Value...
            Attempt RegQueryValueEx(hKey, ValueName, 0, _
                    KeyValType, sTmp, KeyValSize)                           ' Get/Create Key Value
    
            If (Asc(Mid$(sTmp, KeyValSize, 1)) = 0) Then                     ' Win95 Adds Null Terminated String...
                sTmp = Left$(sTmp, KeyValSize - 1)                           ' Null Found, Extract From String
            Else                                                            ' WinNT Does NOT Null Terminate String...
                sTmp = Left$(sTmp, KeyValSize)                               ' Null Not Found, Extract String Only
            End If
    
            ' Determine Key Value Type For Conversion...
            Select Case KeyValType                                          ' Search Data Types...
                Case REG_SZ                                                 ' String Registry Key Data Type
                    sReturn = sTmp '(Do nothing)
                Case REG_DWORD                                              ' Double Word Registry Key Data Type
                    For i = Len(sTmp) To 1 Step -1                          ' Convert Each Bit
                        sByte = Hex(Asc(Mid$(sTmp, i, 1)))
                        Do Until Len(sByte) = 2
                            sByte = "0" & sByte
                        Loop
                        sReturn = sReturn & sByte                           ' Build Value Char. By Char.
                    Next
                    sReturn = Format$("&h" + sReturn)                       ' Convert Double Word To String
            End Select
    
            GetKeyValue = True
            ValueData = sReturn
    
    LocalErr:
            On Error Resume Next
            RegCloseKey hKey
        End If
    End Function
    
    Private Sub Attempt(rc As Long)
        If (rc <> ERROR_SUCCESS) Then
            Err.Raise 5
        End If
    End Sub
    
    Private Function ValidKeyName(KeyName As String) As Boolean
        'A key name is invalid if it begins or ends with \ or contains \\
        If Left$(KeyName, 1) <> gsSLASH_BACKWARD Then
            If Right$(KeyName, 1) <> gsSLASH_BACKWARD Then
                If InStr(KeyName, gsSLASH_BACKWARD & gsSLASH_BACKWARD) = 0 Then
                    ValidKeyName = True
                End If
            End If
        End If
    End Function
    I'd search the forums, though, it may save having to reinvent the wheel.

    HTH

    joshAU

  13. #13

    Thread Starter
    Fanatic Member coolcurrent4u's Avatar
    Join Date
    Apr 2008
    Location
    *****
    Posts
    993

    Question Re: Scan FOR Hardware

    thanks again

    but i get an unknown error, i found another class from PSC

    but how do i have vb detect uninstalled hardware

    ??
    thanks

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