DLL内の関数アドレスを取得 <TOP>
GetModuleHandle 指定の実行モジュールのハンドルを取得
LoadLibrary DLLをロード
GetProcAddress 実行モジュール内の関数アドレスを取得
FreeLibrary ロードしたDLLの解放
'================================================================ '= DLL内の関数アドレスを取得 '= (GetProcAddress.bas) '================================================================ #include "Windows.bi" ' 指定の実行モジュールのハンドルを取得 Declare Function Api_GetModuleHandle& Lib "Kernel32" Alias "GetModuleHandleA" (ByVal ModuleName$) ' DLLをロード Declare Function Api_LoadLibrary& Lib "Kernel32" Alias "LoadLibraryA" (ByVal lpLibFileName$) ' 実行モジュール内の関数アドレスを取得 Declare Function Api_GetProcAddress& Lib "Kernel32" Alias "GetProcAddress" (ByVal ModuleHandle&, ByVal ProcName$) ' ロードしたDLLの解放 Declare Sub Api_FreeLibrary Lib "Kernel32" Alias "FreeLibrary" (ByVal hLibModule&) Var Shared Edit1 As Object Var Shared Edit2 As Object Var Shared Text1 As Object Var Shared Text2 As Object Var Shared Button1 As Object Edit1.Attach GetDlgItem("Edit1") : Edit1.SetFontSize 14 Edit2.Attach GetDlgItem("Edit2") : Edit2.SetFontSize 14 Text1.Attach GetDlgItem("Text1") : Text1.SetFontSize 14 Text2.Attach GetDlgItem("Text2") : Text2.SetFontSize 14 Button1.Attach GetDlgItem("Button1") : Button1.SetFontSize 14 '================================================================ '= '================================================================ Declare Function IsFunctionExported(sFunction As String, sModule As String) As Integer Function IsFunctionExported(sFunction As String, sModule As String) As Integer Var hMod As Long Var Loaded As Integer 'DLLのハンドルを取得 hMod = Api_GetModuleHandle(sModule) If hMod = 0 Then hMod = Api_LoadLibrary(sModule) If hMod Then Loaded = True End If If hMod Then If Api_GetProcAddress(hMod, sFunction) Then IsFunctionExported = True End If If Loaded Then Api_FreeLibrary(hMod) End Function '================================================================ '= '================================================================ Declare Sub Button1_on edecl () Sub Button1_on() If IsFunctionExported(Edit2.GetWindowText, Edit1.GetWindowText) Then A% = MessageBox("", "Dllに「" & Edit2.GetWindowText & "」は、存在します!", 0, 2) Else A% = MessageBox("", "Dllに「" & Edit2.GetWindowText & "」は、存在しません!", 0, 2) End If End Sub '================================================================ '= '================================================================ While 1 WaitEvent Wend Stop End