Search code examples
c++visual-studio-2008cstring

CString error, 'CString': is not a member of 'ATL::CStringT<BaseType, StringTraits>'


I am trying to do this:

#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);

But I am getting the compiler error C2039:'CString': is not a member of 'ATL::CStringT'

This is a non MFC based dll, but according to the docs you should be able to use CString functionality with the include #include atlstr.h how do I make it work?

Thanks


Solution

  • That's not how constructors are invoked in C++.

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

    Note that GetModuleFilename expects a pointer to an array of characters (which it fills), not a pointer to a single character. Your code is therefore doomed to crash at runtime.