其他分享
首页 > 其他分享> > ATL中CA2T乱码问题

ATL中CA2T乱码问题

作者:互联网

This code:

Copy
LPCTSTR szr = CA2T(szReplaceFile);   
is equivalent to this:```


```cpp
LPCTSTR szr;
{
   CA2T temp(szReplaceFile);
   szr = temp.operator LPTSTR();
}   

As the memory allocated by the temporary object and returned from the cast operator is destroyed when the temporary object is destroyed, using the value in szr will have undesirable results.

Instead, use this code:

CA2T szr(szReplaceFile);   

The cast operator makes the CA2T object look like a LPCTSTR.

标签:LPCTSTR,ATL,object,szReplaceFile,乱码,operator,CA2T,szr
来源: https://blog.csdn.net/qq_39008744/article/details/122082135