Skip to content

Instantly share code, notes, and snippets.

@kumatti1
Last active January 8, 2021 04:13
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kumatti1/9ee4a363f2d634a4c8c2 to your computer and use it in GitHub Desktop.
Save kumatti1/9ee4a363f2d634a4c8c2 to your computer and use it in GitHub Desktop.
Endステートメント
Option Explicit
Private Declare PtrSafe Function GetModuleHandle Lib "kernel32" Alias "GetModuleHandleA" (ByVal lpModuleName As String) As LongPtr
Private Declare PtrSafe Function GetProcAddress Lib "kernel32" (ByVal hModule As LongPtr, ByVal lpProcName As String) As LongPtr
Private Declare PtrSafe _
Function DispCallFunc Lib "OleAut32.dll" ( _
ByVal pvInstance As LongPtr, _
ByVal oVft As LongPtr, _
ByVal cc_ As Long, _
ByVal vtReturn As Integer, _
ByVal cActuals As Long, _
ByRef prgvt As Integer, _
ByRef prgpvarg As LongPtr, _
ByRef pvargResult As Variant _
) As Long
Const CC_CDECL = 1
Private Declare PtrSafe Function LoadLibrary Lib "kernel32" Alias "LoadLibraryA" (ByVal lpLibFileName As String) As LongPtr
Private Declare PtrSafe Function FreeLibrary Lib "kernel32" (ByVal hLibModule As LongPtr) As Long
Sub hoge()
Dim hDll As LongPtr
hDll = LoadLibrary("msvbvm60.dll")
If hDll = 0 Then Exit Sub
'__vbaEnd
Dim proc As LongPtr
proc = GetProcAddress(hDll, "__vbaEnd")
If proc = 0 Then Exit Sub
Dim hr As Long
Dim Ret As Variant
Dim v1, v2
v1 = Empty
v2 = Empty
hr = DispCallFunc(0, proc, CC_CDECL, vbLong, 0, v1, v2, Ret)
Debug.Print Hex$(hr)
FreeLibrary hDll
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment