7,763
社区成员
发帖
与我相关
我的任务
分享
/* 回调函数模型定义 */
typedef void (*LPVBFUN)(void);
/* API函数定义 lpVBFunction 为VB回调函数*/
void _stdcall YourAPI(LPVBFUN lpVBFunction)
{
lpVBFunction();
}
Private Declare Sub YourAPI Lib "YourAPI.dll" (lpVBFunction As Any)
Private Sub Form_Load()
YourAPI AddressOf VBFunction
End Sub
Private Sub VBFunction()
MsgBox "这是VB回调函数"
End Sub
// a.cpp : Defines the entry point for the DLL application.
//
#include "stdafx.h"
extern "C" void _declspec(dllexport) CallVBFunction(void);
//void CallFunc(void)
__declspec(naked) void CallVBFunction(void)
{
__asm
{
pop eax; //返回地址出栈
pop ecx; //函数指针出栈
push eax; //返回地址入栈
jmp ecx; //调用函数
}
}