c++ - CString 错误, 'CString' : is not a member of 'ATL::CStringT<BaseType, StringTraits>'

标签 c++ visual-studio-2008 cstring

我正在尝试这样做:

#include <atlstr.h>

CHAR Filename; // [sp+26Ch] [bp-110h]@1
char v31; // [sp+36Ch] [bp-10h]@1
int v32; // [sp+378h] [bp-4h]@1

 GetModuleFileNameA(0, &Filename, 0x100u);
 CString::CString(&v31, &Filename);

但我收到编译器错误 C2039:'CString': is not a member of 'ATL::CStringT'

这是一个非基于 MFC 的 dll,但根据文档,您应该能够使用包含 #include atlstr.h 的 CString 功能,我如何让它工作?

谢谢

最佳答案

这不是在 C++ 中调用构造函数的方式。

CString s = CString(&v21,&File);

请注意,GetModuleFilename 需要一个指向字符数组(它填充)的指针,而不是指向单个字符的指针。因此,您的代码注定会在运行时崩溃。

关于c++ - CString 错误, 'CString' : is not a member of 'ATL::CStringT<BaseType, StringTraits>' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4565739/

相关文章:

c++ - 运行时错误 : addition of unsigned offset

带有枚举的 C++ Visual Studio 调试器错误

c# - 防止 Visual Studio 添加新类的默认引用和使用

visual-studio-2008 - Visual Studio 2013 + Business Intelligence SSDT 中缺少 Reporting Server 模板

c++ - 使用 strcpy() 获取 char* 的一部分会导致程序崩溃

c++ - 使用成员变量的地址作为ID

c++ - 通过取消引用迭代器将 Vector 写入文件

windows - 使用免费软件在 Windows 上生成 64 位版本

c++ - 是否有任何用 C/C++ 编码的回归测试来测试 CString (ATL/MFC) 的所有功能?

c - fmemopen 不写入 c 字符串