我必須excecute一個exe這是一些驅動器,我怎麼能做到這一點使用C++提供?如何用C++創建一個進程來執行exe?
我做這樣的
#include <stdio.h>
#include <conio.h>
#include <windows.h>
void main()
{
STARTUPINFO si;
PROCESS_INFORMATION pi;
ZeroMemory(&si, sizeof(si));
si.cb = sizeof(si);
ZeroMemory(&pi, sizeof(pi));
if(!CreateProcess(L"c:\\DOTNET.exe",NULL,NULL, NULL,FALSE, 0,NULL,NULL,&si,&pi))
{
printf("CreateProcess failed (%d).\n", GetLastError());
}
else
{
printf("Prcess Creation Success");
}
WaitForSingleObject(pi.hProcess, INFINITE);
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
getch();
}
但每一次它顯示進程的創建失敗,錯誤代碼2(即找不到指定的路徑),但我放置在DOTNET.exe C:\ DOTNET .exe只。
什麼是錯在上述code.can任何一個建議我...
任何幫助greately感激..
Thabks提前。
之間的區別c:\和c:\只是一個錯字?你有沒有試過系統(...)而不是CreateProcess(...)? – Beta 2009-07-23 15:59:45
你能從命令行運行「c:\\ dotnet.exe」嗎? – 2009-07-23 16:02:18