字符串。 TCHAR LPWCS LPCTSTR CString。什么是这里,简单快速 [英] Strings. TCHAR LPWCS LPCTSTR CString. Whats what here, simple quick

查看:189
本文介绍了字符串。 TCHAR LPWCS LPCTSTR CString。什么是这里,简单快速的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

TCHAR szExeFileName[MAX_PATH]; 
GetModuleFileName(NULL, szExeFileName, MAX_PATH);

CString tmp;
lstrcpy(szExeFileName, tmp);
CString out;
out.Format("\nInstall32 at %s\n", tmp);
TRACE(tmp);

错误(格式化):

error C2664: 'void ATL::CStringT<BaseType,StringTraits>::Format(const wchar_t 
*,...)' : cannot convert parameter 1 from 'const char [15]' to 'const wchar_t

我只想得到当前路径从它启动并复制到一个CString,所以我可以在其他地方使用它。我目前只是试图通过TRACE'ing它看到的路径。但字符串,字符,字符数组,我不能得到所有的海峡。

I'd just like to get the current path that this program was launched from and copy it into a CString so I can use it elsewhere. I am currently just try to get to see the path by TRACE'ing it out. But strings, chars, char arrays, I can't ever get all the strait. Could someone give me a pointer?

推荐答案

我的猜测是在Unicode模式下编译。

My guess is you are compiling in Unicode mode.

尝试在_T宏中包含您的格式字符串,这是为了提供始终正确的提供常量字符串参数的方法,而不管您是以Unicode还是ANSI模式编译:

Try enclosing your format string in the _T macro, which is designed to provide an always-correct method of providing constant string parameters, regardless of whether you're compiling in Unicode or ANSI mode:

out.Format(_T("\nInstall32 at %s\n"), tmp);

这篇关于字符串。 TCHAR LPWCS LPCTSTR CString。什么是这里,简单快速的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆