字符串到LPCWSTR [英] string to LPCWSTR
本文介绍了字符串到LPCWSTR的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好,
我正在使用ShellExecute打开具有以下功能的Web浏览器:
hello,
I am using ShellExecute to open a web browser with this function:
#include <windows.h>;
void google(string args)
{
string URL ("http://www.google.com/search?q=");
URL.append(args);
ShellExecute(NULL, L"open", URL, NULL, NULL, SW_SHOWNORMAL);
}
</windows.h>
但我不断收到错误消息:
错误C2664:"ShellExecuteW":无法将参数3从"std :: string"转换为"LPCWSTR""
没有人知道如何将字符串更改为LPCWSTR或解决此问题的方法吗?
thanx
but I keep on getting the error message :
"error C2664: ''ShellExecuteW'' : cannot convert parameter 3 from ''std::string'' to ''LPCWSTR''"
does any one know how to change a string to a LPCWSTR or a way around this problem?
thanx
推荐答案
此处: http://msdn. microsoft.com/en-us/library/dd319072 [ ^ ]
或者,您也可以使用:ShellExecuteA
Here: http://msdn.microsoft.com/en-us/library/dd319072[^]
or you can use: ShellExecuteA
转换为const char *首先使用.c_str(),然后使用char *加上static_cast,如果需要的话,最后转换为LPCWSTR.您还可以通过使用多字节字符集而不是Unicode来更改所需的类型,并且可以修改您需要转换为的类型.
Convert to const char * first use .c_str(), then char * with static_cast if needed, and finally convert to LPCWSTR if necessary. You also might be able to change the type required by using Multi-Byte Character Set instead of Unicode, and that may modify the type you need to cast to.
这篇关于字符串到LPCWSTR的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文