Click here to Skip to main content
16,010,114 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: NetServerEnum Pin
Vipul Bhatt27-Oct-02 22:50
Vipul Bhatt27-Oct-02 22:50 
GeneralRe: NetServerEnum Pin
Richard Deeming30-Sep-02 4:02
mveRichard Deeming30-Sep-02 4:02 
GeneralRe: NetServerEnum Pin
Vipul Bhatt30-Sep-02 20:07
Vipul Bhatt30-Sep-02 20:07 
GeneralRe: NetServerEnum Pin
Richard Deeming30-Sep-02 23:44
mveRichard Deeming30-Sep-02 23:44 
GeneralRe: NetServerEnum Pin
Vipul Bhatt1-Oct-02 1:53
Vipul Bhatt1-Oct-02 1:53 
GeneralRe: NetServerEnum Pin
Vipul Bhatt1-Oct-02 1:57
Vipul Bhatt1-Oct-02 1:57 
GeneralRegEnumKeyEx and WinXP Pin
stefan b28-Sep-02 6:38
stefan b28-Sep-02 6:38 
GeneralRe: RegEnumKeyEx and WinXP Pin
Nick Parker28-Sep-02 17:37
protectorNick Parker28-Sep-02 17:37 
Try this, it works on WinXP:
Const ERROR_NO_MORE_ITEMS = 259&
Const HKEY_CURRENT_CONFIG = &H80000005
Const HKEY_LOCAL_MACHINE = &H80000002
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Private Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult 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 String, lpcbClass As Long, lpftLastWriteTime As Any) As Long
Private Declare Function RegEnumValue Lib "advapi32.dll" Alias "RegEnumValueA" (ByVal hKey As Long, ByVal dwIndex As Long, ByVal lpValueName As String, lpcbValueName As Long, ByVal lpReserved As Long, lpType As Long, lpData As Any, lpcbData As Long) As Long
Private Sub Form_Load()
    Dim hKey As Long, Cnt As Long, sName As String, sData As String, Ret As Long, RetData As Long
    Const BUFFER_SIZE As Long = 255
    'Set the forms graphics mode to persistent
    Me.AutoRedraw = True
    Me.Print "RegEnumKeyEx"
    Ret = BUFFER_SIZE
    'Open the registry key
    If RegOpenKey(HKEY_LOCAL_MACHINE, "Hardware", hKey) = 0 Then
        'Create a buffer
        sName = Space(BUFFER_SIZE)
        'Enumerate the keys
<font color="red">
        While RegEnumKeyEx(hKey, Cnt, sName, Ret, ByVal 0&, vbNullString, ByVal 0&, ByVal 0&) <> ERROR_NO_MORE_ITEMS
            'Show the enumerated key
            Me.Print "  " + Left$(sName, Ret)
            'prepare for the next key
            Cnt = Cnt + 1
            sName = Space(BUFFER_SIZE)
            Ret = BUFFER_SIZE
        Wend
</font>
        'close the registry key
        RegCloseKey hKey
    Else
        Me.Print "  Error while calling RegOpenKey"
    End If
    Me.Print vbCrLf + "RegEnumValue"
    Cnt = 0
    'Open a registry key
    If RegOpenKey(HKEY_LOCAL_MACHINE, "Software\Microsoft\Windows\CurrentVersion", hKey) = 0 Then
        'initialize
        sName = Space(BUFFER_SIZE)
        sData = Space(BUFFER_SIZE)
        Ret = BUFFER_SIZE
        RetData = BUFFER_SIZE
        'enumerate the values
        While RegEnumValue(hKey, Cnt, sName, Ret, 0, ByVal 0&, ByVal sData, RetData) <> ERROR_NO_MORE_ITEMS
            'show data
            If RetData > 0 Then Me.Print "  " + Left$(sName, Ret) + "=" + Left$(sData, RetData - 1)
            'prepare for next value
            Cnt = Cnt + 1
            sName = Space(BUFFER_SIZE)
            sData = Space(BUFFER_SIZE)
            Ret = BUFFER_SIZE
            RetData = BUFFER_SIZE
        Wend
        'Close the registry key
        RegCloseKey hKey
    Else
        Me.Print "  Error while calling RegOpenKey"
    End If
End Sub


Nick Parker

The goal of Computer Science is to build something that will last at least until we've finished building it. - Unknown



GeneralRe: RegEnumKeyEx and WinXP Pin
stefan b29-Sep-02 5:59
stefan b29-Sep-02 5:59 
QuestionHow to declare constants Pin
sybux200027-Sep-02 7:46
sybux200027-Sep-02 7:46 
AnswerRe: How to declare constants Pin
Ray Cassick27-Sep-02 7:59
Ray Cassick27-Sep-02 7:59 
Generalsimple question Pin
ns27-Sep-02 6:18
ns27-Sep-02 6:18 
GeneralRe: simple question Pin
Paul Riley27-Sep-02 6:33
Paul Riley27-Sep-02 6:33 
GeneralRe: simple question Pin
ns27-Sep-02 8:47
ns27-Sep-02 8:47 
GeneralRe: simple question Pin
Nick Parker27-Sep-02 9:12
protectorNick Parker27-Sep-02 9:12 
GeneralRe: simple question Pin
Paul Riley27-Sep-02 10:34
Paul Riley27-Sep-02 10:34 
GeneralRe: simple question Pin
Nick Parker28-Sep-02 17:39
protectorNick Parker28-Sep-02 17:39 
Questionhow to implement progress bar for any process or procedure ? Pin
drmzunlimited26-Sep-02 21:29
drmzunlimited26-Sep-02 21:29 
GeneralFindFirstFile Pin
Anonymous26-Sep-02 21:00
Anonymous26-Sep-02 21:00 
GeneralRe: FindFirstFile Pin
BhaskarG10-Oct-02 19:31
BhaskarG10-Oct-02 19:31 
Questionhow to get results from a select query and view them in VB.net in a form?? Pin
drmzunlimited26-Sep-02 8:25
drmzunlimited26-Sep-02 8:25 
AnswerRe: how to get results from a select query and view them in VB.net in a form?? Pin
Peet Schultz26-Sep-02 19:46
Peet Schultz26-Sep-02 19:46 
General"class does not support automation..." error Pin
ns26-Sep-02 6:16
ns26-Sep-02 6:16 
GeneralRe: "class does not support automation..." error Pin
Nick Parker26-Sep-02 17:38
protectorNick Parker26-Sep-02 17:38 
GeneralRe: "class does not support automation..." error Pin
ns27-Sep-02 0:40
ns27-Sep-02 0:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.