在dll中的函数为:int Startup(int port,int interval)
int WINAPI Close();我的调用dll源代码:
int (* StartServer) (int, int) = NULL;
HINSTANCE hinstance = NULL;
hinstance = LoadLibrary("theDLL.dll");
StartServer = (int (*) (int, int)) GetProcAddress(hinstance, "Startup");
(*lpfnStartServer)(1, 20);我可以得到该函数的地址,但是调用(*lpfnStartServer)(1, 20)时出错。而且我得到的dll函数Startup和Close的地址是一样的(得到Close函数地址的代码没有给出)。请大家指点,谢谢啦。
int WINAPI Close();我的调用dll源代码:
int (* StartServer) (int, int) = NULL;
HINSTANCE hinstance = NULL;
hinstance = LoadLibrary("theDLL.dll");
StartServer = (int (*) (int, int)) GetProcAddress(hinstance, "Startup");
(*lpfnStartServer)(1, 20);我可以得到该函数的地址,但是调用(*lpfnStartServer)(1, 20)时出错。而且我得到的dll函数Startup和Close的地址是一样的(得到Close函数地址的代码没有给出)。请大家指点,谢谢啦。
2.dll中的函数声明是否这样
int WINAPI Startup(int port,int interval);
如果是的话调用端也应该这样声明
2.dll中的函数声明是否这样
int WINAPI Startup(int port,int interval);
如果是的话调用端也应该这样声明
typedef int (*StartServer)(int,int);
HINSTANCE hInst = ::LoadLibrary("theDLL.dll");
StartServer StartServerFun=NULL;
StartServerFun= (StartServer)GetProAddress(hInst,"Startup");
int nResult=StartServerFun(1,20);
所以声明的函数指针:typedef int (WINAPI *StartServer)(int,int);就对了,谢谢大家了。
所以声明函数指针 typedef int (WINAPI *StartServer)(int,int);就可以了
谢谢大家了。