| 发表于:2007-04-18 11:09:19 楼主 |
dll文件 .h public: virtual bool initinstance(); _declspec(dllexport) int addvalue(int a,int b); //声明了一下 declare_message_map() .cpp int ctestdllapp::addvalue(int a,int b) { int c; c=a+b; return c; } 测试程序 void ctdllcxdlg::onbnclickedbutton1() { // todo: 在此添加控件通知处理程序代码 typedef int(* addvalue)(int a,int b); hinstance hdll=null; addvalue add1=null; int e=5; int f=2; int m; cstring str1=null; hdll=loadlibrary( "testdll.dll "); if(hdll==null) { messagebox( "could not load dll "); } add1=(addvalue)getprocaddress(hdll, "addvalue "); m=add1(e,f); str1.format( "%d ",m); messagebox(str1); freelibrary(hdll); } dll文件编译也通过了,loadlibrary也成了 但是运行到m=add1(e,f)真正使用这个函数时就异常终止了 问为什么?? |
|
|
|
|