windows下用createProcess创建进程示例代码
时间: 2023-12-25 11:47:10 浏览: 48
好的,以下是一个使用CreateProcess创建进程的示例代码:
```
#include <windows.h>
#include <stdio.h>
int main()
{
STARTUPINFO si;
PROCESS_INFORMATION pi;
ZeroMemory(&si, sizeof(si));
si.cb = sizeof(si);
ZeroMemory(&pi, sizeof(pi));
// Set the path for the executable to run
wchar_t path[] = L"C:\\Windows\\System32\\cmd.exe";
// Start the process
if (!CreateProcess(path, NULL, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
{
printf("CreateProcess failed (%d).\n", GetLastError());
return 1;
}
// Wait for the process to finish
WaitForSingleObject(pi.hProcess, INFINITE);
// Close the handles
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
return 0;
}
```
请问还有什么其它问题吗?