⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vc++动态链接库编程之mfc规则dll-开发者网络-vc-天极yesky.htm

📁 从网上下载的关于学习动态链接库的连载教程
💻 HTM
📖 第 1 页 / 共 3 页
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
<!-- saved from url=(0038)http://dev.yesky.com/241/2144741.shtml -->
<HTML lang=zh-CN xmlns="http://www.w3.org/1999/xhtml"><HEAD><TITLE>VC++动态链接库编程之MFC规则DLL-开发者网络-VC-天极Yesky</TITLE>
<META content=VC++动态链接库编程之MFC规则DLL, name=description>
<META content=VC++动态链接库编程之MFC规则DLL, name=keywords>
<META content="天极Yesky | 全球中文IT第一门户" name=author>
<META content="天极Yesky | 全球中文IT第一门户" name=Copyright>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<META http-equiv=Content-Language content=zh-CN><LINK media=all 
href="VC++动态链接库编程之MFC规则DLL-开发者网络-VC-天极Yesky.files/y_mobile_content.css" 
type=text/css rel=stylesheet>
<SCRIPT src="VC++动态链接库编程之MFC规则DLL-开发者网络-VC-天极Yesky.files/showlay.js"></SCRIPT>

<META content="MSHTML 6.00.2900.3199" name=GENERATOR></HEAD>
<BODY><!--页面头部--><!--头部-->
<DIV id=topmenu><A href="http://www.yesky.com/">Yesky首页</A>| <A 
href="http://product.yesky.com/">产品报价</A>| <A 
href="http://cseek.yesky.com/">行情</A>| <A href="http://mobile.yesky.com/">手机</A> 
| <A href="http://digital.yesky.com/">数码</A> | <A 
href="http://notebook.yesky.com/">笔记本</A> | <A 
href="http://pc.yesky.com/">台式机</A> | <A href="http://diy.yesky.com/">DIY硬件</A> 
| <A href="http://oa.yesky.com/">外设</A> | <A href="http://net.yesky.com/">网络</A> 
| <A href="http://dh.yesky.com/">数字家庭</A> | <A 
href="http://lab.yesky.com/">评测</A> | <A href="http://soft.yesky.com/">软件</A> | 
<A href="http://e.yesky.com/">e时代</A> | <A href="http://game.yesky.com/">游戏</A> 
| <A href="http://pic.yesky.com/">图片</A> | <A 
href="http://desktop.yesky.com/">壁纸</A> | <A href="http://q.yesky.com/">群乐</A> | 
<A href="http://my.yesky.com/">社区</A> | <A href="http://blog.yesky.com/">博客</A> 
| <A href="http://www.mydown.com/">下载</A></DIV>
<DIV id=topbox>
<DIV class=tleft><A href="http://www.yesky.com/"><IMG alt=天极Yesky_全球中文IT第一门户 
src="VC++动态链接库编程之MFC规则DLL-开发者网络-VC-天极Yesky.files/logo.gif" border=0></A></DIV>
<DIV class=tad><SPAN id=ad1></SPAN></DIV>
<DIV id=search>
<DIV>
<FORM name=searchform action=http://search.chinabyte.com/search method=get 
target=_blank><INPUT id=searchzz onmouseover=this.focus() onfocus=this.select() 
name=q><INPUT type=hidden value=GB2312 name=encoding><INPUT type=hidden 
value=connect name=dir><INPUT type=hidden value=20002 name=cid><INPUT id=search_btn type=submit value=天极搜索> </FORM></DIV>
<DIV class=tdq>
<DIV class=rightarea><A href="http://bj.yesky.com/">北京</A> <A 
href="http://hd.yesky.com/">上海</A> <A href="http://gd.yesky.com/">广东</A> <A 
href="http://xa.yesky.com/">西安</A><BR><A href="http://cq.yesky.com/">重庆</A> <A 
href="http://cd.yesky.com/">成都</A> <A href="http://sy.yesky.com/">沈阳</A> <A 
href="http://js.yesky.com/">江苏</A> </DIV>
<DIV class=rightarea_right><A 
href="http://my.yesky.com/">用户<BR>登录</A></DIV></DIV></DIV>
<DIV class=tright>
<DIV class=box1>
<SCRIPT src="VC++动态链接库编程之MFC规则DLL-开发者网络-VC-天极Yesky.files/content_text_ad.js" 
type=text/javascript></SCRIPT>
</DIV></DIV></DIV>
<SCRIPT src="VC++动态链接库编程之MFC规则DLL-开发者网络-VC-天极Yesky.files/flash.js" 
type=text/javascript></SCRIPT>

<DIV id=childmenu><A href="http://soft.yesky.com/">软件频道&gt;</A><A 
href="http://dev.yesky.com/">程序开发&gt;</A><A 
href="http://dev.yesky.com/devjava/">Java</A><A 
href="http://dev.yesky.com/ysdevvb">VB</A><A 
href="http://dev.yesky.com/ysdevvc">VC</A><A 
href="http://dev.yesky.com/ysdevdelphi">Delphi</A><A 
href="http://dev.yesky.com/ysdevc">C/C++</A><A 
href="http://dev.yesky.com/web/">Web开发</A><A 
href="http://dev.yesky.com/msdn/">微软专栏</A><A 
href="http://dev.yesky.com/devydkf/">移动</A><A 
href="http://dev.yesky.com/devsjk/">数据库</A><A 
href="http://dev.yesky.com/ysdevcxrs">程序人生</A><A 
href="http://dev.yesky.com/ysdevrjgc">软件工程</A>|<A 
href="http://soft.yesky.com/lesson/">产品中心</A><A 
href="http://www.mydown.com/soft/develop/news.shtml">下载</A><A 
href="http://q.yesky.com/group/202019"><FONT color=#ff0000>群乐:<FONT 
face=Verdana>Vista系统</FONT></FONT></A></DIV><!--导航条-->
<DIV id=location>
<DIV class=loleft>您现在的位置: <A href="http://www.yesky.com/">天极网</A> &gt; <A 
href="http://dev.yesky.com/">开发频道</A> &gt; VC++动态链接库编程之MFC规则DLL</DIV>
<DIV class=adright><SPAN id=ad2></SPAN></DIV></DIV><!--内容块开始-->
<DIV id=conbox><!--左边开始-->
<DIV id=conleft>
<DIV id=contopla1>
<DIV id=__001>
<DIV class=qkong></DIV>
<DIV class=qw1>全文</DIV>
<DIV class=zkong>
<DIV class=kl></DIV>
<DIV class=bj><A href="http://dev.yesky.com/241/2144741.shtml#pls" 
target=_self>评论</A></DIV>
<DIV class=kr></DIV>
<SCRIPT type=text/javascript>
var titiepic ="#";
if (titiepic!="#")
{
document.write("<div class=\"kl\"></div><div class=\"bj\"><a href=\"#\" target=\"_blank\">图片</a></div><div class=\"kr\"></div>");
}
</SCRIPT>
</DIV></DIV></DIV>
<DIV class=topadbg><SPAN id=ad10></SPAN></DIV><A name=top></A>
<DIV id=contitle>
<H1>VC++动态链接库编程之MFC规则DLL</H1></DIV>
<DIV id=conauthor><SPAN>2005-10-09 10:52 </SPAN><SPAN>作者: 宋宝华 </SPAN><SPAN>出处: 
作者授权转载 </SPAN><SPAN>责任编辑:<A title=向本编辑提问 
href="http://comments.yesky.com/t/·&frac12;&Ouml;&Ucirc;/6,324/2144741.shtml" target=_blank>方舟</A> 
</SPAN></DIV>
<DIV class=topadbg><SPAN id=ad9></SPAN></DIV>
<DIV id=conneirong><SPAN id=ad3></SPAN>
<TABLE cellSpacing=1 cellPadding=2 width=600 align=center bgColor=#ff3300 
border=0>
  <TBODY>
  <TR bgColor=#ffffff>
    <TD bgColor=#cc0000 colSpan=4><A 
      href="http://soft.yesky.com/lesson/"><FONT 
      color=#ffffff><B>天极软件专题专区精选</B></FONT></A>     <A 
      href="http://comments.yesky.com/t/100913/6,324/2069547.shtml" 
      target=_blank><FONT color=#ffffff><B>到天极软件“读编交流区”畅所欲言</B></FONT></A></TD></TR>
  <TR bgColor=#ffffff>
    <TD width="25%"><A href="http://soft.yesky.com/tools/google">Google专区</A> 
    </TD>
    <TD width="23%"><A href="http://soft.yesky.com/tools/popo">POPO专区</A></TD>
    <TD width="24%"><A href="http://qq.yesky.com/">QQ专区</A> <A 
      href="http://soft.yesky.com/lesson/401/2047901.shtml">QQ挂机</A></TD>
    <TD width="28%"><A 
      href="http://soft.yesky.com/327/2055327.shtml">了解Web2.0</A></TD></TR>
  <TR bgColor=#ffffff>
    <TD width="25%"><A href="http://design.yesky.com/flash/mx/">Flash MX 
      视频教程</A></TD>
    <TD width="23%"><A 
      href="http://soft.yesky.com/SoftChannel/72348986094125056/20040623/1823629.shtml">Photoshop视频教程</A></TD>
    <TD width="24%"><A 
      href="http://www.yesky.com/259/1926759.shtml">网页设计视频教程</A></TD>
    <TD width="28%"><A 
      href="http://www.yesky.com/SoftChannel/72348986094125056/20050430/1943944.shtml">照片处理数字暗房</A></TD></TR>
  <TR bgColor=#ffffff>
    <TD width="25%"><A 
      href="http://www.yesky.com/SoftChannel/72348968914255872/20050517/1950125.shtml">PPT动画演示教程</A></TD>
    <TD width="23%"><A 
      href="http://soft.yesky.com/SoftChannel/72348968914255872/20050126/1905902.shtml">Excel动画教程集</A></TD>
    <TD width="24%"><A 
      href="http://soft.yesky.com/SoftChannel/72348968914255872/20050223/1914058.shtml">Word动画演示教程</A></TD>
    <TD width="28%"><A href="http://soft.yesky.com/os/vista/">Windows 
      Vista专区</A> </TD></TR>
  <TR bgColor=#ffffff>
    <TD width="25%" height=18><A 
      href="http://soft.yesky.com/security/muma/">特洛伊木马专区</A></TD>
    <TD width="23%" height=18><A 
      href="http://soft.yesky.com/security/hkjc/">黑客知识教程专区</A></TD>
    <TD width="24%" height=18><A 
      href="http://soft.yesky.com//security/firewall/">防火墙应用专区</A></TD>
    <TD width="28%" height=18><A 
      href="http://soft.yesky.com/os/zcb/">注册表应用专区</A></TD></TR>
  <TR bgColor=#ffffff>
    <TD width="25%"><A href="http://soft.yesky.com/lesson/vbapi/" 
      target=_blank>Windows API开发专区</A></TD>
    <TD width="23%"><A href="http://soft.yesky.com/lesson/network/" 
      target=_blank>网络编程专区</A></TD>
    <TD width="24%"><A href="http://soft.yesky.com/lesson/vbdatabase/" 
      target=_blank>VB数据库编程专区</A></TD>
    <TD width="28%"><A 
      href="http://soft.yesky.com/lesson/multimedia/">图像处理与多媒体编程</A></TD></TR></TBODY></TABLE><BR>  第4节我们对非MFC 
DLL进行了介绍,这一节将详细地讲述MFC规则DLL的创建与使用技巧。 
<BR><BR>  另外,自从本文开始连载后,收到了一些读者的e-mail。有的读者提出了一些问题,笔者将在本文的最后一次连载中选取其中的典型问题进行解答。由于时间的关系,对于读者朋友的来信,笔者暂时不能一一回复,还望海涵!由于笔者的水平有限,文中难免有错误和纰漏,也热诚欢迎读者朋友不吝指正!<BR><BR>
<DIV class=guanggao><SPAN id=contentAdv></SPAN></DIV>  5. MFC规则DLL<BR><BR>  5.1 
概述<BR><BR>  MFC规则DLL的概念体现在两方面:<BR><BR>  (1) 
它是MFC的<BR>  <BR>  “是MFC的”意味着可以在这种DLL的内部使用MFC;<BR><BR>  (2) 
它是规则的<BR><BR>  “是规则的”意味着它不同于MFC扩展DLL,在MFC规则DLL的内部虽然可以使用MFC,但是其与应用程序的接口不能是MFC。而MFC扩展DLL与应用程序的接口可以是MFC,可以从MFC扩展DLL中导出一个MFC类的派生类。<BR><BR>  Regular 
DLL能够被所有支持DLL技术的语言所编写的应用程序调用,当然也包括使用MFC的应用程序。在这种动态连接库中,包含一个从CWinApp继承下来的类,DllMain函数则由MFC自动提供。<BR><BR>  Regular 
DLL分为两类:<BR><BR>  (1)静态链接到MFC 的规则DLL<BR><BR>  静态链接到MFC的规则DLL与MFC库(包括MFC扩展 
DLL)静态链接,将MFC库的代码直接生成在.dll文件中。在调用这种DLL的接口时,MFC使用DLL的资源。因此,在静态链接到MFC 
的规则DLL中不需要进行模块状态的切换。<BR><BR>  使用这种方法生成的规则DLL其程序较大,也可能包含重复的代码。<BR><BR>  (2)动态链接到MFC 
的规则DLL<BR><BR>  动态链接到MFC 的规则DLL 可以和使用它的可执行文件同时动态链接到 MFC DLL 和任何MFC扩展 
DLL。在使用了MFC共享库的时候,默认情况下,MFC使用主应用程序的资源句柄来加载资源模板。这样,当DLL和应用程序中存在相同ID的资源时(即所谓的资源重复问题),系统可能不能获得正确的资源。因此,对于共享MFC 
DLL的规则DLL,我们必须进行模块切换以使得MFC能够找到正确的资源模板。<BR><BR>  我们可以在Visual 
C++中设置MFC规则DLL是静态链接到MFC DLL还是动态链接到MFC DLL。如图8,依次选择Visual C++的project -&gt; 
Settings -&gt; General菜单或选项,在Microsoft Foundation Classes中进行设置。<BR><BR>
<TABLE width="90%" align=center border=0>
  <TBODY>
  <TR>
    <TD>
      <DIV align=center><IMG 
      src="VC++动态链接库编程之MFC规则DLL-开发者网络-VC-天极Yesky.files/496tcjb95zkf.jpg" 
      border=0><BR>图8 设置动态/静态链接MFC DLL</DIV></TD></TR></TBODY></TABLE><BR>  5.2 
MFC规则DLL的创建<BR><BR>  我们来一步步讲述使用MFC向导创建MFC规则DLL的过程,首先新建一个project,如图9,选择project的类型为MFC 
AppWizard(dll)。点击OK进入如图10所示的对话框。<BR><BR>
<TABLE width="90%" align=center border=0>
  <TBODY>
  <TR>
    <TD>
      <DIV align=center><IMG 
      src="VC++动态链接库编程之MFC规则DLL-开发者网络-VC-天极Yesky.files/181ysg7l3l3w.jpg" 
      border=0><BR>图9 MFC DLL工程的创建</DIV></TD></TR></TBODY></TABLE><BR>
<TABLE width="90%" align=center border=0>
  <TBODY>
  <TR>
    <TD>
      <DIV align=center><IMG 
      src="VC++动态链接库编程之MFC规则DLL-开发者网络-VC-天极Yesky.files/vem5qtksd311.jpg" 
      border=0><BR>图10所示对话框中的1区选择MFC 
DLL的类别。</DIV></TD></TR></TBODY></TABLE><BR>  2区选择是否支持automation(自动化)技术, 
automation 允许用户在一个应用程序中操纵另外一个应用程序或组件。例如,我们可以在应用程序中利用 Microsoft Word 或Microsoft 
Excel的工具,而这种使用对用户而言是透明的。自动化技术可以大大简化和加快应用程序的开发。<BR><BR>  3区选择是否支持Windows 
Sockets,当选择此项目时,应用程序能在 TCP/IP 网络上进行通信。 
CWinApp派生类的InitInstance成员函数会初始化通讯端的支持,同时工程中的StdAfx.h文件会自动include 
&lt;AfxSock.h&gt;头文件。<BR><BR>  添加socket通讯支持后的InitInstance成员函数如下: <BR><BR>
<TABLE borderColor=#cccccc width="90%" align=center bgColor=#e3e3e3 border=1>
  <TBODY>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -