安装 .CAB WM 后重新启动
在 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 安装中看到一条礼貌消息显示“需要重新启动才能完成安装...”,没有“确定/取消”按钮。然后设备会在显示该消息两秒后重新启动。此外,该软件可以毫无问题地卸载。
我希望实现与上述其他 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;
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 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;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
从这个线程我明白需要通知安装过程安装 CAB 软件包后需要重新启动。
因此,只需返回
CONFIG_S_REBOOTREQUIRED
(不带 SetSystemPowerState)即可代替codeINSTALL_EXIT_DONE
。我通常使用
ExitWindowsEx
重新启动 WindowsSetSystemPowerState
.ExitWindowsEx(EWX_REBOOT | EWX_DEFER, 0);
应该异步重新启动,以便有时间完成安装过程。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 returnCONFIG_S_REBOOTREQUIRED
(without SetSystemPowerState).I usually restart windows with
ExitWindowsEx
instead ofSetSystemPowerState
.ExitWindowsEx(EWX_REBOOT | EWX_DEFER, 0);
should restart asynchronously, giving time to the setup process to finish.