zoukankan      html  css  js  c++  java
  • 升级基于ATL3.0的项目到ATL7.0(VC6.0 to VS2008)[移植变更点]

          ATL3.0与7.0在实现细节方面改变比较多,其中对原来的模版类进行了拆分,实现更为细致。同时,从VC6移过来的程序,为了保证其后的兼容性,如果不是Unicode,最好在本次升级中一步到位。

    具体变更:

    MyCom程序

    ATL 3.0(VC6.0 / ANSI)

    ATL 7.0 (Unicode)

    主线程文件: class CMyComApp

    MyCom.cpp中实现:

    在dllmian.cpp中实现;

    涉及到主线程相关的函数都在此实现;

    Dll注册函数:

    DllRegisterServer

    DllGetClassObject

    MyCom.cpp中实现:

    MyCom.cpp中实现;(该文件中只剩下注册相关的操作)

    CComModule

    ATL 3.0 提供了 CComModule 类。

    CComModule _module;

    在 ATL 7.0 中,以前由 CComModule 提供的功能由若干新类处理:

    关于句柄相关:

    使用CAtlBaseModulet替换:

    关于DLL注册相关:

    使用CMyComModule:继承自CAtlDllModuleT

    获取句柄

    _Module.GetModuleInstance()

    _AtlBaseModule.GetModuleInstance() (引用:在altcore.h:extern CAtlBaseModule _AtlBaseModule;

    LPCSTR-》CString

    直接赋值

    LPCSTR str;

    CString s = CString(str);

    字符串CString赋值

    CString section = "IBECOM";

    CString section = _T("IBECOM");

    字符串、函数在unicode下的改变:

    Char drive[_MAX_DRIVE];

    _splitpath( strFileName, drive, dir, fname, ext );

    使用unicode,则相应的字符串变量申明都改为宽字符:

    wchar_t drive[_MAX_DRIVE];

    同样,使用对应的宽字符函数:

    _wsplitpath(strFileName, drive, dir, fname, ext );

    字符串转换:

    CString->LPSTR

    Cstring str; // ansi环境string

    LPSTR ls = str;

    CString str;// unicode环境string

    LPSTR ls = new char[str.GetLength()+1];

    USES_CONVERSION;

    lps = W2A(str);

    当然,如果在源头都改为char_t更好,也就避免了这样的转换。

    更多细节请参考:http://msdn.microsoft.com/zh-cn/library/w1sc4t4k.aspx

    OVER

    本文链接:http://blog.donews.com/me1105/archive/2010/11/26/49.aspx

  • 相关阅读:
    TabControl添加关闭按钮
    C# 遍历窗体上控件方法
    个人JS脚本验证大全[转]
    c# 窗体位置任意调
    Sql存储过程解密算法 破解微软的加密算法
    网页居中
    兼容IE和Firefox的设为首页和收藏的Javascript代码
    定义类成员
    HikariCP
    post请求重定向到get请求问题
  • 原文地址:https://www.cnblogs.com/me115/p/1888562.html
Copyright © 2011-2022 走看看