开发者

What is the difference between CreateProcess and CreateProcessA?

开发者 https://www.devze.com 2023-01-03 15:18 出处:网络
what is the difference between CreateProcess and CreateProcessA, also are there any alternatives to these in VC++ 2008 ?

what is the difference between CreateProcess and CreateProcessA, also are there any alternatives to these in VC++ 2008 ?

I have als开发者_运维问答o a problem, that i use the CreateProcessA function, this works well in one system but fails in other systems.

Also when i use CreateProcess i get the error cannot convert 2 parameter from 'CHAR[40]' to 'LPWSTR' i am in unicode mode


First, CreateProcess is a macro that switches between CreateProcessA and CreateProcessW, which take strings in ANSI or Unicode, respectively. This depends on your project build settings (the character set project property), Unicode vs Multi-Byte. Generally, you want things to be in Unicode, as this allows for globalization and adds the option of allowing more supported languages.

The complaint in converting from char to LPCWSTR shows that it's expecting a type of WSTR, or wide string, or unicode string. A workaround is to declare your chars using the _T("blahblah") macro.


CreateProcess is identical to either CreateProcessA ("ANSI") or to CreateProcessW ("Wide characters"), depending on whether you're compiling your code without or with the unicode option enabled.

The difference is whether the string which you pass as a parameter should be an ANSI (8-bit character) or a unicode (16-bit character) string.


There are also alternatives, like ShellExecuteEx.

0

精彩评论

暂无评论...
验证码 换一张
取 消