You need to do something like:
CreateProcess(L"C:\\identify.exe",csExecute.GetBuffer(),0,0,TRUE, NORMAL_PRIORITY_CLASS|CREATE_NO_WINDOW,0,0,&sInfo,&pInfo);
CreateProcess() for some reason wants to write a buffer for the command line parameter, so the implicit conversion of CString to a plain old pointer will not happen (since it will only perform the implicit conversion if it is a const pointer).
If this is not the problem you are experiencing, send more details about the error or unexpected behavior that you are working in.
As an example, the following program launches a small utility program that resets the command line specified to it:
int main() { CString csExecute = "some string data"; STARTUPINFO sInfo = {0}; sInfo.cb = sizeof(sInfo); PROCESS_INFORMATION pInfo = {0}; CreateProcess(L"C:\\util\\echoargs.exe",csExecute.GetBuffer(),0,0,TRUE, NORMAL_PRIORITY_CLASS,0,0,&sInfo,&pInfo); return 0; }
source share