Este es el ejemplo que te dije
Option Explicit
'KERNEL32
Private Declare Sub CopyMemory Lib "KERNEL32" Alias "RtlMoveMemory" (ByRef Destination As Any, ByRef Source As Any, ByVal Length As Long)
Private Declare Function CallWindowProc Lib "USER32" Alias "CallWindowProcW" (ByVal lpPrevWndFunc As Long, ByVal hwnd As Long, ByVal msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Public Function Invoke(ByVal lpCode As Long, ParamArray vParams() As Variant) As Long
Dim i As Long
Dim lPtr As Long
Dim bvASM(&HFF) As Long
lPtr = VarPtr(bvASM(&H0))
Call AddByte(&H58, lPtr) '//POP EAX
Call AddLong(&H59595959, lPtr) '//POP ECX (x4)
Call AddByte(&H50, lPtr) '//PUSH EAX
For i = UBound(vParams) To LBound(vParams) Step -1
Call AddByte(&H68, lPtr) '//PUSH ________
Call AddLong(CLng(vParams(i)), lPtr) '//____ XXXXXXXX
Next i
Call AddCall(lpCode, lPtr) '//CALL lpCode
Call AddByte(&HC3, lPtr) '//RET
Invoke = CallWindowProc(VarPtr(bvASM(&H0)), ByVal 0&, ByVal 0&, ByVal 0&, ByVal 0&)
End Function
Private Sub AddCall(ByVal lpPtrCall As Long, ByRef lPtr As Long)
Call AddByte(&HE8, lPtr) '//CALL ________
Call AddLong(lpPtrCall - lPtr - 4, lPtr) '//____ XXXXXXXX
End Sub
Private Sub AddLong(ByVal lLong As Long, ByRef lPtr As Long)
Call CopyMemory(ByVal lPtr&, lLong, &H4)
lPtr = lPtr + &H4
End Sub
Private Sub AddByte(ByVal bByte As Byte, ByRef lPtr As Long)
Call CopyMemory(ByVal lPtr&, bByte, &H1)
lPtr = lPtr + &H1
End Sub
Ejemplo de uso:
Private Declare Function LoadLibrary Lib "kernel32.dll" Alias "LoadLibraryA" (ByVal lpLibFileName As String) As Long
Private Declare Function GetProcAddress Lib "kernel32.dll" (ByVal hModule As Long, ByVal lpProcName As String) As Long
Private Sub Form_Load()
Dim hMod As Long
hMod = GetProcAddress(LoadLibrary("KERNEL32"), "Beep")
Call Invoke(hMod, 200, 500)
End Sub