It doesn't work because the _T()
macro works only with constant string literals. The definition for _T()
looks something like this:
#ifdef UNICODE
#define _T(str) L##str
#else
#define _T(str) str
Since you're apparently compiling in Unicode mode, _T(full)
expands to Lfull
, which is obviously not what you want.
In your case, just pass in full
without the _T()
macro since CString
defines a conversion operator to a const wchar_t*
in Unicode mode, and const char*
in non-Unicode mode.
ShellExecute(0, _T("open"), _T("c:\IECapt"), full, 0, SW_HIDE);
Note that standard C++ also provides a std::string
type and a std::wstring
type which does pretty much what CString
does, so MFC isn't actually required for string manipulation. std::string
does not provide a conversion operator, but does provide access to the underlying C-style string via c_str()
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…