レジストリのキーを列挙(U) <TOP>
RegEnumKeyEx 指定された開いているレジストリーキーのサブキーを列挙
RegOpenKeyEx レジストリのキーのハンドルを確保
RegCloseKey レジストリのハンドルを解放
参考
SHEnumKeyEx との違いは、FILETIME構造体より最終書き込み時間が取得できることです。
'================================================================ '= レジストリのキーを列挙(U) '= (RegEnumKeyEx.bas) '================================================================ #include "Windows.bi" #define HKEY_CURRENT_USER -2147483647 '現在Windowsにログインしているユーザーの情報 #define ERROR_SUCCESS &H0 '正常終了の戻り値を示す #define KEY_ALL_ACCESS &H3F ' Type FILETIME dwLowDateTime As Long dwHighDateTime As Long End Type ' 指定された開いているレジストリーキーのサブキーを列挙 Declare Function Api_RegEnumKeyEx& Lib "advapi32" Alias "RegEnumKeyExA" (ByVal hKey&, ByVal dwIndex&, ByVal lpName$, ByRef lpcbName&, ByVal lpReserved&, ByVal lpClass$, ByRef lpcbClass&, ByRef lpftLastWriteTime As FILETIME) ' レジストリのキーのハンドルを確保 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 ft As FILETIME 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_RegEnumKeyEx(lKey, i, sName, lName, 0, sClass, lClass, ft) 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