WinRar 退出代码在 SP2/SP3 和 7 中的不同行为

发布于 2024-11-30 13:28:57 字数 1907 浏览 1 评论 0原文

我是 Windows 编程新手,并且使用 mingw 编写了一个小实用程序,它将解压缩一个包。代码如下

描述:

运行以下程序时,结果如下

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版本的trail模式。

I am new to windows programming and have written a small utility with mingw which will unrar a package. The code is as provided below

Descrition:

When the below program is run, the results are as follows

XPSP2 32 bit and Windows 7

  • Untar Operation : Success
  • CreateProcess return code : Non Zero (Success)
  • exit Code : 0 (Success)

XP2SP3 32 bit

  • Untar Operation : Success
  • CreateProcess return code : Non Zero (Success)
  • exit Code : 3221225477

Problem Statement

I am not sure why in XP2SP3 patch only, the winRar operation provides the exit code as Huge positive value. Do you find any problem in the below code? Please help in this regard.


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 version trail Mode is used for above testing.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

阪姬 2024-12-07 13:28:57

这个巨大的正数(十六进制)是 0xC0000005。这是一个常见的 Windows 错误,意思是“访问冲突”。为什么你会得到它实际上取决于 winrar 试图做什么,但问题可能在于文件的访问权限。我建议您尝试使用 ProcMon 监视程序的文件活动。如果访问其中一个文件被拒绝,您将在日志中看到它。

That huge positive number, in hexadecimal, is 0xC0000005. It's a common Windows error, which means "Access Violation". Why exactly are you getting it really depends on what winrar is trying to do, but the problem might be with access rights to files. I suggest you give it a try with ProcMon watching your program's file activity. If accessing one of the files is denied, you'll see it in the log.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文