0

在 Windows Mobile 6 或 CE 5 设备上,我需要安装 CAB 文件,然后启动重新启动。

我知道自定义操作。您需要在本机 C++ 中为 CAB 文件创建 setup.dll。

所以我已经制作了以下代码

codeINSTALL_EXIT Install_Exit(HWND hwndParent,
                              LPCTSTR pszInstallDir,
                              WORD cFailedDirs,
                              WORD cFailedFiles,
                              WORD cFailedRegKeys,
                              WORD cFailedRegVals,
                              WORD cFailedShortcuts)
{
    MessageBox(hwndParent,
               _T("A reboot is required to complete installation, Press OK to reboot."),
               _T("Reboot required"),
               MB_OK);
    SetSystemPowerState(NULL, POWER_STATE_RESET, 0);
    return codeINSTALL_EXIT_DONE;
}

SetSystemPowerState 将对设备进行热启动。问题是,由于安装未完成(INSTALL_EXIT_DONE未达到返回码),它会抱怨当您稍后尝试将其删除时它无法安装应用程序。删除重新启动是解决此问题的即时方法。

我在其他 .CAB 安装上看到了一条礼貌的消息"A restart is required to complete installation...",显示没有确定/取消按钮。然后设备在显示消息两秒钟后重新启动。此外,可以毫无问题地卸载该软件。

我希望实现与上述其他 CAB 文件相同的功能,一个超时系统弹出窗口,然后是重新启动以及从设备上的删除程序选项中卸载应用程序的能力。


我昨天发现的另一个可能的解决方案是返回 CONFIG_S_REBOOTREQUIRED 。但是,这没有定义,因此不会编译。codeINSTALL_EXIT 的定义返回如下。

Using typedef enum
{
    codeINSTALL_EXIT_DONE       = 0,    // @comm Exit the installation successfully
    codeINSTALL_EXIT_UNINSTALL          // @comm Uninstall the application before exiting the installation
}
codeINSTALL_EXIT;
4

1 回答 1

2

这个线程我了解到,安装 CAB 包后需要通知安装过程需要重新启动。

因此,codeINSTALL_EXIT_DONE不仅仅是返回CONFIG_S_REBOOTREQUIRED(没有 SetSystemPowerState)。

ExitWindowsEx我通常使用而不是重新启动 Windows SetSystemPowerStateExitWindowsEx(EWX_REBOOT | EWX_DEFER, 0); 应该异步重新启动,为设置过程留出时间来完成。

于 2010-09-07T08:40:01.300 回答