レジストリ

  RegEx.bas



  
Global Const HKEY_CLASSES_ROOT = &H80000000
Global Const HKEY_CURRENT_USER = &H80000001
Global Const HKEY_LOCAL_MACHINE = &H80000002
Global Const HKEY_USERS = &H80000003
Global Const HKEY_PERFORMANCE_DATA = &H80000004
Global Const HKEY_CURRENT_CONFIG = &H80000005
Global Const HKEY_DYN_DATA = &H80000006

Const READ_CONTROL = &H20000
Const WRITE_DAC = &H40000
Const WRITE_OWNER = &H80000
Const SYNCHRONIZE = &H100000

Const STANDARD_RIGHTS_READ = (READ_CONTROL)
Const STANDARD_RIGHTS_WRITE = (READ_CONTROL)
Const STANDARD_RIGHTS_EXECUTE = (READ_CONTROL)
Const STANDARD_RIGHTS_REQUIRED = &HF0000
Const STANDARD_RIGHTS_ALL = &H1F0000

Const KEY_QUERY_VALUE = &H1
Const KEY_SET_VALUE = &H2
Const KEY_CREATE_SUB_KEY = &H4
Const KEY_ENUMERATE_SUB_KEYS = &H8
Const KEY_NOTIFY = &H10
Const KEY_CREATE_LINK = &H20
Const KEY_READ = _
    ((STANDARD_RIGHTS_READ _
    Or KEY_QUERY_VALUE _
    Or KEY_ENUMERATE_SUB_KEYS _
    Or KEY_NOTIFY) _
    And (Not SYNCHRONIZE))
Const KEY_WRITE = _
    ((STANDARD_RIGHTS_WRITE _
    Or KEY_SET_VALUE _
    Or KEY_CREATE_SUB_KEY) _
   And (Not SYNCHRONIZE))
Const KEY_ALL_ACCESS = _
    ((STANDARD_RIGHTS_ALL _
    Or KEY_QUERY_VALUE _
    Or KEY_SET_VALUE _
    Or KEY_CREATE_SUB_KEY _
    Or KEY_ENUMERATE_SUB_KEYS _
    Or KEY_NOTIFY _
    Or KEY_CREATE_LINK) _
    And (Not SYNCHRONIZE))

Declare Function lbRegOpenKeyEx Lib "advapi32.dll" Alias "RegOpenKeyExA" ( _
    ByVal hKey As Long, _
    ByVal lpSubKey As String, _
    ByVal ulOptions As Long, _
    ByVal samDesired As Long, _
    phkResult As Long _
) As Long

Declare Function lbRegCloseKey Lib "advapi32.dll" Alias "RegCloseKey" ( _
    ByVal hKey As Long _
) As Long

Type lbRegFILETIME
        dwLowDateTime As Long
        dwHighDateTime As Long
End Type
Declare Function lbRegEnumKeyEx 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 lbRegFILETIME _
) As Long

Declare Function lbRegEnumValue 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 Byte, _
    lpcbData As Long _
) As Long

Global WshForReg As Variant

' ******************************************************
' レジストリキーを開く
' ******************************************************
Public Function lbRegOpen(hKey As Long, SubKey As String)

    Dim ret As Long
    Dim hNew As Long

    ret = lbRegOpenKeyEx(hKey, SubKey, 0, KEY_ALL_ACCESS, hNew)
    If ret = 0 Then
        lbRegOpen = hNew
    Else
        lbRegOpen = False
    End If

End Function

' ******************************************************
' 値の列挙
' ******************************************************
Public Function lbRegEnumData(Grid As Object, hKey As Long, SubKey As String)

    Grid.Cols = 4
    If Not IsObject(WshForReg) Then
        Set WshForReg = CreateObject("WScript.Shell")
    End If
    
    Dim hNew As Long
    Dim idx As Long
    Dim strValueName As String * 512
    Dim Data(512) As Byte
    Dim nValueNameSize As Long
    Dim nDataSize As Long
    Dim nType As Long
    
    hNew = lbRegOpen(hKey, SubKey)
    If hNew = 0 Then
        lbRegEnumValue = False
        Exit Function
    End If

    idx = 0
    Do
        nValueNameSize = 512
        nDataSize = 512
        If 259 = lbRegEnumValue( _
                hNew, _
                idx, _
                strValueName, _
                nValueNameSize, _
                0, _
                nType, _
                Data(0), _
                nDataSize _
            ) Then
            Exit Do
        End If
        idx = idx + 1
        Grid.Rows = idx + 1
        Grid.TextMatrix(idx, 1) = strValueName
        Grid.TextMatrix(idx, 2) = nType
    
    Loop

    Call lbRegCloseKey(hNew)
    Grid.Sort = 1
    
    Dim TargetRoot As String
    
    Select Case hKey
        Case HKEY_CLASSES_ROOT
            TargetRoot = "HKEY_CLASSES_ROOT"
        Case HKEY_CURRENT_USER
            TargetRoot = "HKEY_CURRENT_USER"
        Case HKEY_LOCAL_MACHINE
            TargetRoot = "HKEY_LOCAL_MACHINE"
        Case HKEY_USERS
            TargetRoot = "HKEY_USERS"
        Case HKEY_CURRENT_CONFIG
            TargetRoot = "HKEY_CURRENT_CONFIG"
    End Select
    
    For idx = 1 To Grid.Rows - 1
        Grid.TextMatrix(idx, 3) = _
            WshForReg.RegRead(TargetRoot & "\" & SubKey & "\" & Grid.TextMatrix(idx, 1))
    Next
    
End Function

' ******************************************************
' キーの列挙
' ******************************************************
Public Function lbRegEnumKey(Grid As Object, hKey As Long, SubKey As String)

    Grid.Cols = 2
    
    Dim hNew As Long
    Dim idx As Long
    Dim strKeyName As String * 512
    Dim FileTime As lbRegFILETIME
    Dim nKeyNameSize As Long
    
    hNew = lbRegOpen(hKey, SubKey)
    If hNew = 0 Then
        lbRegEnumKey = False
        Exit Function
    End If

    idx = 0
    Do
        nKeyNameSize = 512
        If 259 = lbRegEnumKeyEx( _
                hNew, _
                idx, _
                strKeyName, _
                nKeyNameSize, _
                0, _
                0, _
                0, _
                FileTime _
            ) Then
            Exit Do
        End If
        idx = idx + 1
        Grid.Rows = idx + 1
        Grid.TextMatrix(idx, 1) = strKeyName
    
    Loop

    Call lbRegCloseKey(hNew)
    Grid.Sort = 1
    
End Function

  










  infoboard   管理者用   
このエントリーをはてなブックマークに追加




SQLの窓  天気  IT用語辞典
Yahoo!ニュース  マルチ辞書
PHP マニュアル  Google URL短縮 


フリーフォントWEBサービス
SQLの窓WEBサービス

SQLの窓フリーソフト

素材

一般WEBツールリンク

SQLの窓

フリーソフト

JSライブラリ