レジストリのキーを列挙(T) <TOP>
SHEnumKeyEx レジストリのサブキーを列挙
RegOpenKeyEx レジストリのキーのハンドルを確保
RegCloseKey レジストリのハンドルを解放
参考
'================================================================ '= レジストリのキーを列挙(T) '= (SHEnumKeyEx.bas) '================================================================ #include "Windows.bi" #define HKEY_CURRENT_USER -2147483647 '現在Windowsにログインしているユーザーの情報 #define ERROR_SUCCESS &H0 '正常終了の戻り値を示す #define KEY_ALL_ACCESS &H3F ' ' レジストリのサブキーを列挙 Declare Function Api_SHEnumKeyEx& Lib "Shlwapi" Alias "SHEnumKeyExA" (ByVal hKey&, ByVal dwIndex&, ByVal pszName$, ByRef pcchName&) ' レジストリのキーのハンドルを確保 Declare Function Api_RegOpenKeyEx& Lib "advapi32" Alias "RegOpenKeyExA" (ByVal hKey&, ByVal lpSubKey$, ByVal ulOptions&, ByVal samDesired&, phkResult&) ' レジストリのハンドルを解放 Declare Function Api_RegCloseKey& Lib "advapi32" Alias "RegCloseKey" (ByVal hKey&) Var Shared List1 As Object Var Shared Button1 As Object List1.Attach GetDlgItem("List1") : List1.SetFontSize 14 Button1.Attach GetDlgItem("Button1") : Button1.SetFontSize 14 '================================================================ '= '================================================================ Declare Sub Button1_on edecl () Sub Button1_on() Var lKey As Long Var sSubkey As String Var sName As String Var lName As Long Var sClass As String Var lClass As Long Var i As Long Var Ret As Long sSubkey = "Software" Ret = Api_RegOpenKeyEx(HKEY_CURRENT_USER, sSubkey, 0, KEY_ALL_ACCESS, lKey) If Ret <> ERROR_SUCCESS Then Exit Sub List1.Resetcontent i = 0 Do lName = 1000 lClass = 1000 sName = String$(lName, 0) sClass = String$(lClass, 0) Ret = Api_SHEnumKeyEx(lKey, i, sName, lName) If Ret <> ERROR_SUCCESS Then Exit Do sName = Left$(sName, lName) sClass = Left$(sClass, lClass) List1.AddString sName & ":" & sClass i = i + 1 Loop Ret = Api_RegCloseKey(lKey) End Sub '================================================================ '= '================================================================ While 1 WaitEvent Wend Stop End