wstring-> ShellExecute中的LPCWSTR给我错误LNK2028&LNK2019
|
您好我正在使用UNICODE和/ clr在Visual C ++ 2010(西班牙语)中进行编程。我有一个名为\“ fileFuncs.h \”的头文件:
#include <iostream>
#include <fstream>
#include <string>
#include <stdlib.h>
#include <string>
using namespace std;
std::wstring s2ws(const std::string& s)
{
int len;
int slength = (int)s.length() + 1;
len = MultiByteToWideChar(CP_ACP, 0, s.c_str(), slength, 0, 0);
wchar_t* buf = new wchar_t[len];
MultiByteToWideChar(CP_ACP, 0, s.c_str(), slength, buf, len);
std::wstring r(buf);
delete[] buf;
return r;
}
void callSystem(string sCmd){
std::wstring stemp = s2ws(sCmd);
LPCWSTR params = stemp.c_str();
ShellExecute(NULL,L\"open\",L\"c:\\\\windows\\\\system32\\\\cmd.exe /S /C \",params,NULL,SW_HIDE);
}
但是当我编译时给我这些错误:
错误LNK2028:指的是
未解析的符号(令牌)(0A0004A5)
\“外部\” C \“结构HINSTANCE__ *
stdcall ShellExecuteW(struct HWND *,wchar_t const *,wchar_t const *,wchar_t const *,wchar_t const *,int)\“(?ShellExecuteW @@ $$ J224YGPAUHINSTANCE _ @@ PAUHWND _ @@ PB_W111H @ Z)
在函数“ void __cdecl”中
callSystem(class
std :: basic_string,class
std :: allocator>)\“
(?callSystem @@ $$ FYAXV?$ basic_string @ DU?$ char_traits @ D @ std @@ V?$ allocator @ D @ 2 @@ std @@
错误LNK2019:外部符号
\“外部\” C \“结构HINSTANCE__ *
stdcall ShellExecuteW(struct HWND *,wchar_t const *,wchar_t const *,wchar_t const *,wchar_t const *,int)\“(?ShellExecuteW @@ $$ J224YGPAUHINSTANCE _ @@ PAUHWND _ @@ PB_W111H @ Z)
无效
__cdecl callSystem(class std :: basic_string,classstd :: allocator)\“
功能
(?callSystem @@ $$ FYAXV?$ basic_string @ DU?$ char_traits @ D @ std @@ V?$ allocator @ D @ 2 @@ std @@@ Z)
是某种类型的配置吗?
没有找到相关结果
已邀请:
2 个回复
壬驴拿歪竞
驮帽俺篮号
转换为
,对吗?像大多数带有字符串参数的API函数一样,ShellExecute()具有Ansi和Unicode两种版本。让操作系统为您完成转换: