2012年2月19日 星期日

[ VC(Visual C++) ]-DLL系列(05_函數呼叫MFC對話盒)

[ VC(Visual C++) ]-DLL系列(05_函數呼叫MFC對話盒)



本篇分享函數-函數呼叫MFC對話盒DLL有興趣的(C/P)同好歡迎來http://filemarkets.com/file/jashliao/7b45ebcb/索取因為我不會上傳檔案分享哈哈 ^ ^












主要程式碼:



// mfcdll.cpp : Defines the initialization routines for the DLL.

//

 

#include "stdafx.h"

#include "mfcdll.h"

#include "dlg1.h"

////////////////////////////////////////////////

#pragma data_seg(".SHARDAT")

static HWND      ghWndMain  = 0;

static HHOOK     ghKeyHook = NULL ;

#pragma data_seg()

 

HINSTANCE ghInstance = 0;

HOOKPROC  glpfnHookProc = 0;

/////////////////////////////////////////////////

#ifdef _DEBUG

#definenew DEBUG_NEW

#undef THIS_FILE

staticchar THIS_FILE[] = __FILE__;

#endif

 

//

//    Note!

//

//        If this DLL is dynamically linked against the MFC

//        DLLs, any functions exported from this DLL which

//        call into MFC must have the AFX_MANAGE_STATE macro

//        added at the very beginning of the function.

//

//        For example:

//

//        extern "C" BOOL PASCAL EXPORT ExportedFunction()

//        {

//            AFX_MANAGE_STATE(AfxGetStaticModuleState());

//            // normal function body here

//        }

//

//        It is very important that this macro appear in each

//        function, prior to any calls into MFC.  This means that

//        it must appear as the first statement within the 

//        function, even before any object variable declarations

//        as their constructors may generate calls into the MFC

//        DLL.

//

//        Please see MFC Technical Notes 33 and 58 for additional

//        details.

//

 

/////////////////////////////////////////////////////////////////////////////

// CMfcdllApp

 

BEGIN_MESSAGE_MAP(CMfcdllApp, CWinApp)

    //{{AFX_MSG_MAP(CMfcdllApp)

        // NOTE - the ClassWizard will add and remove mapping macros here.

        //    DO NOT EDIT what you see in these blocks of generated code!

    //}}AFX_MSG_MAP

END_MESSAGE_MAP()

 

/////////////////////////////////////////////////////////////////////////////

// CMfcdllApp construction

 

CMfcdllApp::CMfcdllApp()

{

    // TODO: add construction code here,

    // Place all significant initialization in InitInstance

}

 

/////////////////////////////////////////////////////////////////////////////

// The one and only CMfcdllApp object

int EXPORTED_DLL_FUNCTION KbdHookProc (int a, int b)

{

    int r;

    r=a+b;

    dlg1 d1;

    d1.DoModal(); 

    return (r);

}

CMfcdllApp theApp;

 

BOOL CMfcdllApp::InitInstance() 

{

    // TODO: Add your specialized code here and/or call the base class

    AFX_MANAGE_STATE(AfxGetStaticModuleState());

    ghInstance = AfxGetInstanceHandle();

    return CWinApp::InitInstance();

}

 

int CMfcdllApp::ExitInstance() 

{

    // TODO: Add your specialized code here and/or call the base class

    

    return CWinApp::ExitInstance();

}

 



 


沒有留言:

張貼留言