shamantou blog site

shamantou@gmail.com

导航

关于DLL文件的使用

调试了半个晚上,终于OK~

extern "C" __declspec (dllexport) void warn(int j)

{

         CString str;

         str.Format("%d",j);

         AfxMessageBox("test!_"+str);

}

extern "C" __declspec (dllexport) int ot(int j)

{

         return j;

}

extern "C" __declspec (dllexport) void hello()

{

AfxMessageBox("");

}

         HINSTANCE hd;

         static int j=0;

         j++;

         typedef int(FUNA)(int);

         typedef int(FUNB)(int);

         typedef void(FUNC)(void);

         FUNA* pa;

         FUNB *pb;

         FUNC *pc;

                   hd=LoadLibrary("dll1.dll");

                           pa=(FUNA*)GetProcAddress(hd,"ot");

                            if (!pa)

                            AfxMessageBox("failed in ot");

                           else

                        j=(*pa)(j);

 

                           pb=(FUNB *)GetProcAddress(hd,"warn");

                            if (!pb)

                            AfxMessageBox("failed in warn");

                            else

                            (*pb)(j);

                            pc=(FUNC *)GetProcAddress(hd,"hello");

                            if (!pc)

                                     AfxMessageBox("failed in hello");

                            else

                            (*pc)();

                           FreeLibrary(hd);

<< Jmail发送邮件附件的问题困了 >>

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

最近发表

Powered By Z-Blog 1.8 Arwen Build 81206 Copyright 2006-2009 | ooplab.org | shamantou@gmail.com | 沪ICP备08011244号 | Some Rights Reserved.