惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
H
Hacker News: Front Page
P
Palo Alto Networks Blog
T
ThreatConnect
Apple Machine Learning Research
Apple Machine Learning Research
博客园_首页
T
True Tiger Recordings
P
Privacy & Cybersecurity Law Blog
B
Blog
IT之家
IT之家
Last Week in AI
Last Week in AI
F
Full Disclosure
Hacker News: Ask HN
Hacker News: Ask HN
C
Comments on: Blog
Microsoft Azure Blog
Microsoft Azure Blog
C
Cybersecurity and Infrastructure Security Agency CISA
Microsoft Security Blog
Microsoft Security Blog
博客园 - 【当耐特】
N
News and Events Feed by Topic
NISL@THU
NISL@THU
腾讯CDC
雷峰网
雷峰网
Security Latest
Security Latest
李成银的技术随笔
M
Microsoft Research Blog - Microsoft Research
L
LangChain Blog
L
Lohrmann on Cybersecurity
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
Check Point Blog
Y
Y Combinator Blog
Recent Announcements
Recent Announcements
博客园 - Franky
N
News | PayPal Newsroom
V
V2EX
A
About on SuperTechFans
The Register - Security
The Register - Security
月光博客
月光博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google Online Security Blog
Google Online Security Blog
MyScale Blog
MyScale Blog
Cisco Talos Blog
Cisco Talos Blog
Vercel News
Vercel News
WordPress大学
WordPress大学
C
Cyber Attacks, Cyber Crime and Cyber Security
The Hacker News
The Hacker News
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
爱范儿
爱范儿
A
Arctic Wolf
L
LINUX DO - 最新话题
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

博客园 - vibration

奇怪的引用错误及解决方法 OLE2T在VS2003中转换中文失败的问题及解决方法 标题栏按钮的WTL实现 AppBar的WTL实现 招聘C++和C#开发工程师 ATL组件中文路径注册问题(转载) 关于C++模板的连接问题 - vibration - 博客园 用窗口消息解决COM接口的多线程访问问题 用全局接口表实现COM接口在不同线程中的传递 MyMSN支持自定义内容了 自画菜单的WM_MEASUREITEM只会发送一次 悼念皮皮 上了点照片 一个测试记忆力的小游戏 老板该如何向核心员工许诺 ActiveScript SkinX界面换肤框架更新 反射获取定制Attribute Skin技术实现框架(完)
ATL3.0组件注册bug的解决方法
vibration · 2006-03-24 · via 博客园 - vibration

ATL3.0编写的组件在注册时,如果组件所在目录包含中文路径,不能在注册表生产正确的路径,从而产生虽然注册成功,却不能使用的问题,因为在注册表记录的DLL路径中文部分有乱码。这个问题很久以前就发现,一直没有解决。前段时间在网上搜索到解决方案,并转载在blog上,却一直没有实际试用。今天企图使用,却发现不成功,昏倒,试了几次都不行。看来网上的代码还是不能轻信。不知道文章的作者有没有实际调试成功,不过思路是没错的,因此自己改了下,调通了,这里记录一下。

解决方案:修改STAREG.H文件,修改196行开始的AddChar 和 AddString函数,修改后的代码如下:

        BOOL AddChar(const TCHAR* pch)
        {
            
//if (nPos == nSize) // realloc
            
//fix register bug with chinese path
            if (nPos == nSize - 1 )
            {
                nSize 
*= 2;
                p 
= (LPTSTR) CoTaskMemRealloc(p, nSize*sizeof(TCHAR));
            }
            p[nPos
++= *pch;
#ifndef _UNICODE
            
if (IsDBCSLeadByte(*pch))
                p[nPos
++= *(pch + 1);
#endif
            
return TRUE;
        }
        BOOL AddString(LPCOLESTR lpsz)
        {
            USES_CONVERSION;
            LPCTSTR lpszT 
= OLE2CT(lpsz);
            
while (*lpszT)
            {
                AddChar(lpszT);
#ifndef _UNICODE
                
//fix bug with chinese path
                if (IsDBCSLeadByte(*lpszT))
                    lpszT
++;
#endif
                lpszT
++;
            }
            
return TRUE;
        }

编译时必须使用_ATL_STATIC_REGISTRY,即静态链接ATL代码,而不使用ATL.dll,否则无效,因为正是ATL.dll的代码出了问题。