Note that there are some explanatory texts on larger screens.

plurals
  1. POwstring -> LPCWSTR in ShellExecute give me error LNK2028 & LNK2019
    primarykey
    data
    text
    <p>Hello I'm programming in Visual C++ 2010 (spanish) with UNICODE and /clr. I have a header file called "fileFuncs.h":</p> <pre><code>#include &lt;iostream&gt; #include &lt;fstream&gt; #include &lt;string&gt; #include &lt;stdlib.h&gt; #include &lt;string&gt; using namespace std; std::wstring s2ws(const std::string&amp; 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); } </code></pre> <p>But when I compile give me these errors:</p> <ul> <li><p>error LNK2028: refers to the unresolved symbol (token) (0A0004A5) "extern "C" struct HINSTANCE__ * <strong>stdcall ShellExecuteW(struct HWND</strong> *,wchar_t const *,wchar_t const *,wchar_t const *,wchar_t const *,int)" (?ShellExecuteW@@$$J224YGPAUHINSTANCE_<em>@@PAUHWND</em>_@@PB_W111H@Z) in the function "void __cdecl callSystem(class std::basic_string,class std::allocator >)" (?callSystem@@$$FYAXV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@</p></li> <li><p>error LNK2019: external symbol "extern "C" struct HINSTANCE__ * <strong>stdcall ShellExecuteW(struct HWND</strong> *,wchar_t const *,wchar_t const *,wchar_t const *,wchar_t const *,int)" (?ShellExecuteW@@$$J224YGPAUHINSTANCE_<em>@@PAUHWND</em>_@@PB_W111H@Z) unresolved referred to in "void __cdecl callSystem(class std::basic_string,classstd::allocator)" function (?callSystem@@$$FYAXV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)</p></li> </ul> <p>Is some type of configuration?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload