免费视频淫片aa毛片_日韩高清在线亚洲专区vr_日韩大片免费观看视频播放_亚洲欧美国产精品完整版

打開APP
userphoto
未登錄

開通VIP,暢享免費(fèi)電子書等14項(xiàng)超值服

開通VIP
如何在win32 Application 中使用MFC(轉(zhuǎn))

進(jìn)入 Project-->Setting--> C/C++ Page,做以下修改:

1.    在Preprocessor definitions中加入_AFXDLL,加入后的設(shè)置大概是這樣的:

WIN32,_DEBUG / NODEBUG,[_CONSOLE],[_MBCS],_AFXDLL

加入的_AFXDLL是關(guān)鍵 ,它欺騙MFC LIB,避免連接 MFC 的 WinMain 函數(shù)。

2. 修改Project Options,將 /MT或者 /ML標(biāo)志改為 /MD。

原因是在 afxver_.h 中會檢查_AFXDL, _MT, _DLL 標(biāo)志是否同時設(shè)置,否則報錯。盡管鏈接 For Multi-Threaded 版本的 Library 會損失一些性能,但是這個標(biāo)志的存在并不導(dǎo)致編譯器把 Project 編譯成 DLL。

3.  在Project的 stdafx.h 中包含必要的頭文件,或者直接從MFC AppWizard創(chuàng)建的stdafx.h中拷貝:

#define VC_EXTRALEAN            // Exclude rarely-used stuff from Windows headers

      

#include <afx.h>

#include <afxwin.h>         // MFC core and standard components

#include <afxext.h>         // MFC extensions

#include <afxdtctl.h>           // MFC support for Internet Explorer 4 Common Controls

#ifndef _AFX_NO_AFXCMN_SUPPORT

#include <afxcmn.h>                  // MFC support for Windows Common Controls

#endif // _AFX_NO_AFXCMN_SUPPORT

4.  在Project的WinMain / main中加入MFC的初始化代碼,以下是_tWinMain和_tmain的情況:

extern "C" int WINAPI

_tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,

       LPTSTR lpCmdLine, int nCmdShow)

{

       int nRetCode = 0;

       if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))

       {

              TRACE0("Fatal Error: MFC initialization failed.\n");

              nRetCode = 1;

       }

       else

       {

              // Actual WinMain codes ...

              AfxWinTerm();

       }

       return nRetCode;

}

int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])

{

       int nRetCode = 0;

       if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))

       {

              cerr << _T("Fatal Error: MFC initialization failed") << endl;

              nRetCode = 1;

       }

       else

       {

              // Actual main codes ...

              AfxWinTerm();

       }

       return nRetCode;

}

此外,在Virtual C++ 6.0創(chuàng)建的Win32 Dynamic-Link Library中也可以單獨(dú)使用MFC,這樣可以避免Project被MFC AppWizard和ATL COM AppWizard添加CWinApp實(shí)例,方法簡單,如下構(gòu)造Project的DllMain函數(shù)即可:

#include <afxdllx.h>

static AFX_EXTENSION_MODULE ProjectDLL     = { NULL, NULL };

extern "C" int APIENTRY

DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)

{

       // Remove this if you use lpReserved.

       UNREFERENCED_PARAMETER(lpReserved);

       if (dwReason == DLL_PROCESS_ATTACH)

       {

              // Extension DLL one-time initialization.

              if (!AfxInitExtensionModule(ProjectDLL, hInstance))

              {

                     TRACE0("Project.DLL initialize its extension module failed!\n");

                     return FALSE;

              }

             

              // CDynLinkLibrary’s destructor will be called in AfxTermExtensionModule.

              new CDynLinkLibrary(ProjectDLL);

       }

       elseif (dwReason == DLL_PROCESS_DETACH)

       {

              TRACE0("Project.DLL terminating...\n");

              // Terminate the library before destructors are called.

              AfxTermExtensionModule(ProjectDLL);

       }

       return TRUE;   // ok.

}

本站僅提供存儲服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點(diǎn)擊舉報
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
MFC 如何使用動態(tài)鏈接庫中的資源
DLL導(dǎo)出資源問題的解決
VC++動態(tài)鏈接庫編程之MFC規(guī)則DLL
在DLL中使用資源(二)
MFC運(yùn)行機(jī)制(自認(rèn)為介紹比較清晰的)
深入淺出Win32多線程設(shè)計之MFC的多線程
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長圖 關(guān)注 下載文章
綁定賬號成功
后續(xù)可登錄賬號暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服