search
尋找貓咪~QQ 地點 桃園市桃園區 Taoyuan , Taoyuan

[ VC(Visual C++) ]-DLL系列(01_DLL共享記憶體) – jashliao部落格

[ VC(Visual C++) ]-DLL系列(01_DLL共享記憶體)

本篇要分享DLL共享記憶體,有興趣的(C/P)同好,歡迎來http://filemarkets.com/file/jashliao/d3f5c30a/索取,因為我不會上傳檔案分享  ^ ^

主要程式碼 :

// mfcdll.cpp : Defines the initialization routines for the DLL.
//
 
#include "stdafx.h"
#include "mfcdll.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 jashGetValue ()
{
    return lngtestValue;
}
void EXPORTED_DLL_FUNCTION jashSetValue (int a)
{
    lngtestValue=a;
}
int EXPORTED_DLL_FUNCTION KbdHookProc (int a, int b)
{
    int r;
    r=a+b;
    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();
}

 

 



熱門推薦

本文由 jashliaoeuwordpress 提供 原文連結

寵物協尋 相信 終究能找到回家的路
寫了7763篇文章,獲得2次喜歡
留言回覆
回覆
精彩推薦