开发者

Reboot on installation of .CAB WM

On a Windows Mobile 6 or CE 5 device, I need to install a CAB file and then initiate a reboot.

I am aware of custom actions. You need to create a setup.dll for the CAB file in native C++.

So I have the following code already made

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 will do a warm boot on the device. The problem is that since the installation does not finish (return code INSTALL_EXIT_DONE is not reached), it complains that is it unable to install the application when you attempt to remove it at a later time. Removal of the reboot is an instant cure to this problem.

I have seen on other .CAB installs a polite message appear saying "A restart is required to complete installation..." with no OK/Cancel button. Then the device reboots after two seconds of displaying the message. Furthermore this software can be uninstalled without a problem.

I am looking to achieve the same functionality seen in other CAB files like the above, a timeout system popup, followed by a reboot and the ability to uninstall the application from the remove programs option on the开发者_StackOverflow社区 device.


Another possible solution I found yesterday was to return CONFIG_S_REBOOTREQUIRED instead. However, this is not defined and as such will not compile. The defined returns for codeINSTALL_EXIT are as below.

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;


From this thread I understand that one needs to inform the installing process that a reboot is required after installing the CAB package.

So instead of codeINSTALL_EXIT_DONE just return CONFIG_S_REBOOTREQUIRED (without SetSystemPowerState).

I usually restart windows with ExitWindowsEx instead of SetSystemPowerState.ExitWindowsEx(EWX_REBOOT | EWX_DEFER, 0); should restart asynchronously, giving time to the setup process to finish.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜