Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between CreateProcess and CreateProcessA?

Tags:

visual-c++

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

I have also 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

like image 276
pradeep Avatar asked Jun 17 '10 10:06

pradeep


2 Answers

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.

like image 170
Stefan Valianu Avatar answered Nov 15 '22 16:11

Stefan Valianu


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.

like image 5
ChrisW Avatar answered Nov 15 '22 14:11

ChrisW