• afxstate


    --------------------------------------------------------------------------------
    //afxtls_.h
    --------------------------------------------------------------------------------
    CThreadLocal模板类,这个类很特别,没有数据成员,需要模板参数类型的数据时,都是new出来的

    --------------------------------------------------------------------------------
    //afxstat_.h
    //afxstate.cpp
    --------------------------------------------------------------------------------
    EXTERN_THREAD_LOCAL(_AFX_THREAD_STATE, _afxThreadState)
    THREAD_LOCAL(_AFX_THREAD_STATE, _afxThreadState)

    AFX_THREAD_STATE* AfxGetThreadState();
    AFX_MODULE_STATE* AfxGetModuleState();
    AFX_MODULE_THREAD_STATE* AfxGetModalThreadState();
    Afx_MODULE_STATE* AfxGetStaticModuleState();

    AFX_THREAD_STATE包含AFX_MODULE_STATE* m_pModuleState;AFX_MODULE_STATE* m_pPrevModuleState;
    AFX_MODULE_STATE包含CThreadLocal<AFX_MODULE_THREAD_STATE> m_thread;

    --------------------------------------------------------------------------------
    // 关于AFX_MANAGER_STATE(AfxGetStaticModuleState())
    --------------------------------------------------------------------------------
    // 宏展开
    #define AFX_MANAGE_STATE_NO_INIT_MANAGED(p) AFX_MAINTAIN_STATE2 _ctlState(p);
    #define AFX_MANAGE_STATE(p) _AfxInitManaged(); AFX_MANAGE_STATE_NO_INIT_MANAGED(p)

    // AfxGetStaticModuleState函数
    class _AFX_DLL_MODULE_STATE : public AFX_MODULE_STATE
    {
    public:
        _AFX_DLL_MODULE_STATE() : AFX_MODULE_STATE(TRUE, AfxWndProcDllStatic, _MFC_VER)
            { }
    };

    static _AFX_DLL_MODULE_STATE afxModuleState;
    AFX_MODULE_STATE* AFXAPI AfxGetStaticModuleState()
    {
        AFX_MODULE_STATE* pModuleState = &afxModuleState;
        return pModuleState;
    }

    //AFX_MAINTAIN_STATE2类的构造函数
    AFX_MAINTAIN_STATE2::AFX_MAINTAIN_STATE2(AFX_MODULE_STATE* pNewState) throw()
    {
    #ifdef _AFXDLL
        m_pThreadState = _afxThreadState.GetData();
        ASSERT(m_pThreadState);
        if(m_pThreadState)
        {
            m_pPrevModuleState = m_pThreadState->m_pModuleState;
            m_pThreadState->m_pModuleState = pNewState;
        }
        else
        {
            // This is a very bad state; we have no good way to report the error at this moment
            // since exceptions from here are not expected
            m_pPrevModuleState=NULL;
            m_pThreadState=NULL;
        }
    #endif
    }
  • 相关阅读:
    dfadfas
    Sqlserver修改文件目录,包括系统数据库
    VS2013 产品密钥所有版本
    win11 取消右键更多选项
    VS2013 产品密钥所有版本
    CronTrigger表达式
    C#语言Windows服务程序测试网站发送HTTP请求超时解决办法
    未能写入输出文件“c:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\705b2e0e\c6ba7a68\App_global.asax.v9
    SQL跨数据库复制表数据<转载>
    “服务器应用程序不可用”解决方法
  • 原文地址:https://www.cnblogs.com/gakusei/p/2745179.html
Copyright © 2020-2023  润新知