关于dll写code的一点疑问 答案

本文档介绍了MFC扩展DLL的原理和使用,包括DllMain函数的作用、MFC扩展DLL与规则DLL的区别,以及如何处理编译错误。在示例中,通过创建一个导出MFC派生类的DLL,演示了如何正确地初始化和导出类,从而解决编译问题。
摘要由CSDN通过智能技术生成

// 66.cpp : Defines the entry point for the DLL application.
//

#include "stdafx.h"
#include <afxdllx.h>

static AFX_EXTENSION_MODULE hideDllDLL= {NULL, NULL};
extern "C" int APIENTRY

DllMain( HINSTANCE hInstance,
                       DWORD  ul_reason_for_call,
                       LPVOID lpReserved
                     )
{
    UNREFERENCED_PARAMETER(lpReserved);

    if(ul_reason_for_call == DLL_PROCESS_ATTACH)
    {
        CString szProcessId;
        szProcessId.Format("Hook ProcessId: %d", GetCurrentProcessId());
        AfxMessageBox(szProcessId);
    }
    else if(ul_reason_for_call == DLL_PROCESS_DETACH)
    {
        TRACE0("HIDEDLL.DLL terminating!/n");
        AfxTermExtensionModule(HideDllDLL);
    }

    return TRUE;
}

 

使用win32 dll模式建立,编译出现n多错误,如下

 

--------------------Configuration: 66 - Win32 Debug--------------------
Compiling...
66.cpp
c:/program files/microsoft visual studio/vc98/mfc/include/afxdllx.h(52) : error C2065: 'AFX_MODULE_STATE' : undeclared identifier
c:/program files/microsoft visual studio/vc98/mfc/include/afxdllx.h(52) : error C2065: 'pModuleState' : undeclared identifier
c:/program files/microsoft visual studio/vc98/mfc/include/afxdllx.h(52) : error C2065: 'AfxGetModuleState' : undeclared identifier
c:/program files/microsoft visual studio/vc98/mfc/include/afxdllx.h(52) : error C2106: '=' : left operand must be l-value
c:/program files/microsoft visual studio/vc98/mfc/include/afxdllx.h(53) : error C2227: left of '->m_pClassInit' must point to class/struct/union
c:/program files/micr

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值