你好我正在使用UNICODE和/ clr在Visual C++ 2010(西班牙語)編程。我有一個名爲 「fileFuncs.h」 頭文件:wstring - > ShellExecute中的LPCWSTR給我錯誤LNK2028&LNK2019
#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(結構HWND *,wchar_t的常量*,wchar_t的常量*,wchar_t的常量*,wchar_t的常量*,INT)」(?ShellExecuteW @@ $$ J224YGPAUHINSTANCE_ @@ PAUHWND _ @@ PB_W111H @ Z) 在函數 「空隙__cdecl callSystem(類 的std :: basic_string的,類 的std ::分配器>)」 (?callSystem @@ $$ FYAXV?$ basic_string的@ DU?$ char_traits @ d @ @@性病V ?$ @分配器@ d @@ 2 STD @@
錯誤LNK2019:外部符號 「外部的 「C」 結構HINSTANCE__ * STDCALL ShellExecuteW(HWND結構*,wchar_t的常量*,爲wchar_t常量*,爲wchar_t const?,wchar_t const *,int)「(?ShellExecuteW @@ $$ J224YGPAUHINSTANCE_ @@ PAUHWND _ @@ PB_W111H @ Z) 」void __cdecl callSyst em(class std :: basic_string,classstd :: allocator)「 函數 (?callSystem @@ $$ FYAXV?$ basic_string @ DU?$ char_traits @ D @ std @@ V?$ allocator @ D @ 2 @@ std @@@ Z)
是一些類型的配置?
您是否在鏈接中包含Shell32.lib? – Jollymorphic 2011-04-16 00:55:39
我是C++中的新手。我如何鏈接Shell32.lib? – Galled 2011-04-16 00:59:40