使用Visual Stuido 2012应用程序向导创建MFC DLL

系统环境:Windows8

开发工具:Visual Studio 2012试用版


应用程序向导创建MFC DLL步骤如下:




图一 选择MFC DLL和项目命名


图二 点击Next,详细设置



图三 设置界面1

使用Visual Studio 2012 应用程序向导创建MFC DLL时候有三种DLL类型,每种类型都是什么意思呢?

以下解释摘自stackoverflow

If you use MFC DLL as dynamic linking, your code will need the Microsoft Foundation Library DLL's (specifically the version your code requires) installed along with your application or dll in the user end. So this means your installation package would contain

  • Your application/DLL and supporting files
  • All MFC Dlls

This makes the installation package size go bigger and also make take time for user to download your installation setup.

If you link to MFC as static library, you code will work even without MFC DLLs present at the user end . The reason being pretty simple that all the MFC libraries you refererred in your code, will be linked into your application or dll. This means those MFC libraries used in your app/dll becomes the part of the your binary; however, your app/dll will be little bigger.

以下解释摘自MSDN

MFC 扩展 DLL 是通常实现从现有 Microsoft 基础类库类派生的可重用类的 DLL。

MFC 扩展 DLL 具有下列功能和要求:

  • 客户端可执行文件必须是用定义的 _AFXDLL 编译的 MFC 应用程序。

  • 扩展 DLL 也可由动态链接到 MFC 的规则 DLL 使用。

  • 扩展 DLL 应该用定义的 _AFXEXT 编译。 这将强制同时定义 _AFXDLL,并确保从 MFC 头文件中拉入正确的声明。 它也确保了在生成 DLL 时将 AFX_EXT_CLASS 定义为 __declspec(dllexport),这在使用此宏声明扩展 DLL 中的类时是必要的。

  • 扩展 DLL 不应实例化从 CWinApp 派生的类,而应依赖客户端应用程序(或 DLL)提供此对象。

  • 但扩展 DLL 应提供 DllMain 函数,并在那里执行任何必需的初始化。

扩展 DLL 是使用 MFC 动态链接库版本(也称作共享 MFC 版本)生成的。 只有用共享 MFC 版本生成的 MFC 可执行文件(应用程序或规则 DLL)才能使用扩展 DLL。 客户端应用程序和扩展 DLL 必须使用相同版本的 MFCx0.dll。 使用扩展 DLL,可以从 MFC 派生新的自定义类,然后将此“扩展”版本的 MFC 提供给调用 DLL 的应用程序。

本文最后一图 项目文件展示


  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值