モジュール名の列挙 <TOP>
モジュール名を検索列挙します。
GetCurrentProcessId 自分自身のプロセスIDを取得
CreateToolhelp32Snapshot 最初のモジュールに関する情報を取得
Module32First 最初のモジュールに関する情報を取得
Module32Next 2番目以降のモジュールに関する情報を取得
'================================================================ '= モジュール名の列挙 '= (Module32.bas) '================================================================ #include "Windows.bi" Type MODULEENTRY32 dwSize As Long th32ModuleID As Long th32ProcessID As Long GlblcntUsage As Long ProccntUsage As Long modBaseAddr As Long modBaseSize As Long hModule As Long szModule As String * 256 szExePath As String * 260 End Type ' 自分自身のプロセスIDを取得 Declare Function Api_GetCurrentProcessId& Lib "kernel32" Alias "GetCurrentProcessId" () ' スナップショットを取得 Declare Function Api_CreateToolhelp32Snapshot& Lib "kernel32" Alias "CreateToolhelp32Snapshot" (ByVal lFlags&, ByVal lProcessID&) ' 最初のモジュールに関する情報を取得 Declare Function Api_Module32First& Lib "kernel32" Alias "Module32First" (ByVal hSnapshot&, uProcess As MODULEENTRY32) ' 2番目以降のモジュールに関する情報を取得 Declare Function Api_Module32Next& Lib "kernel32" Alias "Module32Next" (ByVal hSnapshot&, uProcess As MODULEENTRY32) Var Shared Text1 As Object Var Shared List1 As Object Var Shared Button1 As Object List1.Attach GetDlgItem("List1") : List1.SetFontSize 14 List1.SetWindowSize 248, 132 Text1.Attach GetDlgItem("Text1") : Text1.SetFontSize 14 Button1.Attach GetDlgItem("Button1") : Button1.SetFontSize 14 '================================================================ '= '================================================================ Declare Sub Button1_on edecl () Sub Button1_on() Var uProcess As MODULEENTRY32 Var lProcessID As Long Var hSnapshot As Long Var Ret As Long List1.ResetContent lProcessID = Api_GetCurrentProcessId hSnapshot = Api_CreateToolhelp32Snapshot(8, 0) uProcess.dwSize = Len(uProcess) Ret = Api_Module32First(hSnapshot, uProcess) Do While Ret List1.AddString Left$(uProcess.szModule, InStr(uProcess.szModule, Chr$(0)) - 1) Ret = Api_Module32Next(hSnapshot, uProcess) Loop End Sub '================================================================ '= '================================================================ While 1 WaitEvent Wend Stop End