开发者

Use of CreateProcess on WinCE6

I'm trying to launch a process from my program, namely cmd.exe. Doc says I have to use CreateProcess, and below is how I use it :

CreateProcess((LPCWSTR) "\Windows\cmd.exe", (LPCWSTR) "", 0,0,0,0,0,0,0,0); dw = GetLastError(); printf("%u \n", dw);

The path is the one displayed by the target (on the target, I found a shortcut to cmd.exe which states it resides in \windows.

The error is always the same (2), reg开发者_如何学Goardless of how I write the path. Apparently, the error code for (2) is Invalid_Path.

Thanks for having read, GQ


You are passing an incorrect string to create process. Just casting a byte-oriented string to LPCWSTR doesn't fix the problem that it is incorrect data - you really have to use a Unicode string, which you can spell as

CreateProcess(L"\\Windows\\cmd.exe", NULL, 0,0,0,0,0,0,0,0);

Alternatively, you can use the TEXT() macro.


The path is incorrect. Use double backslash.

CreateProcess(TEXT("\\Windows\\cmd.exe"), TEXT(""), 0,0,0,0,0,0,0,0);


Additionally, the last parameter cannot be NULL. It must be a pointer to PROCESS_INFORMATION structure. For details, see the following link

MSDN link for Creating Process in Windows CE 6.0

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜