[英]C++ error when building DLL: argument of type const wchar_t* is incompatible with parameter of type LPWSTR
I am a complete novice to C++ programming.我是 C++ 编程的完全新手。
I need to create a DLL using header and solution files that were provided in a tutorial.我需要使用教程中提供的头文件和解决方案文件创建一个 DLL。 I have followed basic steps from here but, I am getting following errors in the solution file:我已经按照这里的基本步骤进行操作,但是在解决方案文件中出现以下错误:
L111 !CreateProcess(L".\\\\phreeqc\\\\phreeqc.exe",
L111 !CreateProcess(L".\\\\phreeqc\\\\phreeqc.exe",
L112 TEXT(".\\\\phreeqc\\\\phreeqc.exe .\\\\phreeqc\\\\phreeqc_input.txt .\\\\phreeqc\\\\phreeqc_input.out .\\\\phreeqc\\\\wateq4f_plus.dat")
L112 TEXT(".\\\\phreeqc\\\\phreeqc.exe .\\\\phreeqc\\\\phreeqc_input.txt .\\\\phreeqc\\\\phreeqc_input.out .\\\\phreeqc\\\\wateq4f_plus.dat")
Errors:错误:
L111 L111
C2664 'BOOL CreateProcessW(LPCWSTR,LPWSTR,LPSECURITY_ATTRIBUTES,LPSECURITY_ATTRIBUTES,BOOL,DWORD,LPVOID,LPCWSTR,LPSTARTUPINFLOW,LPPROCESS_INFORMATION)': cannot convert argument 2 from 'const wchar_t[105]' to 'LPWSTR' C2664 'BOOL CreateProcessW(LPCWSTR、LPWSTR、LPSECURITY_ATTRIBUTES、LPSECURITY_ATTRIBUTES、BOOL、DWORD、LPVOID、LPCWSTR、LPSTARTUPINFLOW、LPPROCESS_INFORMATION)':无法将参数 2 从 'const wchar_t[105]' 转换为 'LPWSTR'
L112 L112
E0167 argument of type "const wchar_t*" is incompatible with parameter of type "LPWSTR". E0167 “const wchar_t*”类型的参数与“LPWSTR”类型的参数不兼容。
I understand that the specifics in the above lines of code will not mean much to many of you but I am hoping that someone can at least understand the C++ error and help out here.我知道上述代码行中的细节对你们中的许多人来说意义不大,但我希望有人至少可以理解 C++ 错误并在这里提供帮助。
The Unicode version of CreateProcess
(which is a macro that maps to CreateProcessW
) requires a writable string for the lpCommandLine
parameter, and string literals are const
. CreateProcess
的 Unicode 版本(它是一个映射到CreateProcessW
的宏)需要一个可写字符串作为lpCommandLine
参数,并且字符串文字是const
。 You therefore cannot pass a string literal directly for this parameter.因此,您不能直接为此参数传递字符串文字。
Instead, you can change your code like so:相反,您可以像这样更改代码:
WCHAR lpCommandLine [] = L"...";
BOOL ok = CreateProcess (L"your_application_name_here", lpCommandLine, ...);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.