正文

笔记:在vc++的MFC中使用动态链接库2006-11-29 12:56:00

【评论】 【打印】 【字体: 】 本文链接:http://blog.pfan.cn/otot/21018.html

分享到:

使用动态链接库:

1、选择菜单“文件”——“新建”——“工程”——“MFC AppWizard[exe] ”建立一个单窗口程序(命名为“usedll”)
2、为CMyView添加OnLButtonDown处理,添加以下代码:
void CUsedllView::OnLButtonDown(UINT nFlags, CPoint point)
{
 CClientDC dc(this); 
 typedef void(*Ellipse)(CClientDC *pDC,int,int,int,int);
 typedef void(*Rectangle)(CClientDC *pDC,int,int,int,int);
 Ellipse pEllipse;
 Rectangle pRectangle;
 HINSTANCE hInstance=LoadLibrary("D:\\c++\\mydll\\Debug\\mydll.dll");
 PROC fn1=GetProcAddress(hInstance,"DrawEllipse");
 PROC fn2=GetProcAddress(hInstance,"DrawRectangle");
 pEllipse=(Ellipse)fn1;
 pRectangle=(Rectangle)fn2;
 (*pEllipse)(&dc,10,10,100,100);
 (*pRectangle)(&dc,100,100,150,150);
 
 CView::OnLButtonDown(nFlags, point);
}
3、编译运行。

阅读(4592) | 评论(0)


版权声明:编程爱好者网站为此博客服务提供商,如本文牵涉到版权问题,编程爱好者网站不承担相关责任,如有版权问题请直接与本文作者联系解决。谢谢!

评论

暂无评论
您需要登录后才能评论,请 登录 或者 注册