0
我新的Windows編程,並寫有MinGW的一個小工具,將一個的unrar包。作爲下面提供的代碼WinRAR的退出代碼不同的行爲在SP2/SP3和7
Descrition:
當運行下面的程序,結果如下
XPSP2 32位和Windows 7
- 解壓操作:成功
- 的CreateProcess返回代碼:非零(成功)
- 退出代碼:0(成功)
XP2SP3 32位
- 解壓操作:成功
- 的CreateProcess返回代碼:非零(成功)
- 退出代碼:3221225477
問題陳述
我不知道爲什麼在XP2SP3補丁而已,WinRAR的操作提供退出代碼爲巨大正值。你在下面的代碼中發現任何問題嗎?請幫助這方面。
int main()
{
string ProgramName = "C:\\Program Files\\WinRAR\\WinRAR.exe";
STARTUPINFO StartupInfo;
PROCESS_INFORMATION ProcessInfo;
memset(&StartupInfo, 0, sizeof(STARTUPINFO));
memset(&ProcessInfo, 0, sizeof(PROCESS_INFORMATION)
if (CreateProcess((LPCTSTR)ProgramName.c_str(),(LPCTSTR)"WinRAR.exe x -y -ibck d:\\abc.tar d:\\"),NULL,
NULL,
FALSE,
NORMAL_PRIORITY_CLASS,
NULL,
NULL,
&StartupInfo,
&ProcessInfo) == 0)
{
string tmpStr("Error executing");
tmpStr += ProgramName;
cout<<"StmtDesigner"<<tmpStr<<"CreateProcess failed"<<endl;
}
else
{
string tmpStr("Succes executing");
tmpStr += ProgramName;
cout<<"StmtDesigner"<<tmpStr<<"CreateProcess Success"<<endl;
WaitForSingleObject(ProcessInfo.hProcess, INFINITE);
DWORD exitCode=0;
if (GetExitCodeProcess(ProcessInfo.hProcess, &exitCode))
{
string tmpStr("GetExitCodeProcess");
tmpStr += ProgramName;
cout<<tmpStr<<"WinRAR.exe x -y -ibc<<endl;
}
}
CloseHandle(ProcessInfo.hProcess);
CloseHandle(ProcessInfo.hThread);
getch();
return 0;
}
PS:WinRAR的3.8版本線索模式用於上述測試。
0000005被套上存儲器讀/寫/執行沒有足夠的內存訪問權限。這與文件或句柄的訪問權限無關。如果沒有足夠的權限訪問資源,Windows不會引發異常,它會將最後一個錯誤設置爲ERROR_ACCESS_DENIED並返回false。 – pezcode
@pezcode,喜歡還是不喜歡,這就是退出代碼的OP越來越...爲什麼winrar的返回該值我真的不知道。我只能假設winrar正在使用此代碼來指示可訪問性問題。這顯然不是winrar使用錯誤指針的直接結果,但是如果關鍵操作失敗,它可能會返回最後一個錯誤。如果沒有訪問winrar的源代碼,我們只能猜測返回代碼的原因。 – eran
是什麼讓你覺得它「顯然不是一個壞指針的直接結果」?什麼企業程序在進程退出時返回一個Windows定義的異常(!=錯誤)代碼?在這裏回答這些問題的人會有更少的猜測......如果你仍然不相信我,請查看WinRAR手冊:http:// acritum。com /軟件/手冊/ winrar /(命令行模式>退出代碼) – pezcode