windows mobile 部署应用程序 之 setupdll.dll 扩展cab 的行为
windows mobile 部署应用程序 之 setupdll.dll 扩展cab 的行为
1,我们发布windows mobile 程序时,一般要制作*.cab 去在设备安装我们应用程序,那如何在安装时去做一些特殊的行为呢
e.g. 拷贝程序的快捷方式去多个目录, 修改文件名称,创建日志文件 etc.
cab 文件运行时,首先从cab文件中解压出所要安装的文件,如果文件中有setupdll.dll 则setupdll.dll会被隐式的加载,并调用Install_Init,Install_Exit,Uninstall_Init,Uninstall_Exit etc. 函数, 我们可以在编写自己的setupdll.dll 在
Install_Init,Install_Exit,Uninstall_Init,Uninstall_Exit 函数体中实现自己的特殊操作。
下面是托管和本地代码的实现
C#:
using System.Configuration.Install;
public partial class CustomInstaller : Installer
{
public CustomInstaller()
{
InitializeComponent();
this.BeforeInstall +=
new InstallEventHandler(CustomInstaller_BeforeInstall);
}
void CustomInstaller_BeforeInstall(object sender, InstallEventArgs e)
{
//这里写自己的特殊操作
}
}
C++:
// Function Name: Install_Init
//
// Purpose: processes the push message.
//
// Arguments:
// IN HWND hwndParent handle to the parent window
// IN BOOL fFirstCall indicates that this is the first time this function is being called
// IN BOOL fPreviouslyInstalled indicates that the current application is already installed
// IN LPCTSTR pszInstallDir name of the user-selected install directory of the application
//
// Return Values:
// codeINSTALL_INIT
// returns install status
//
// Description:
// The Install_Init function is called before installation begins.
// User will be prompted to confirm installation.
// **************************************************************************
SETUP_API codeINSTALL_INIT Install_Init(
HWND hwndParent,
BOOL fFirstCall, // is this the first time this function is being called?
BOOL fPreviouslyInstalled,
LPCTSTR pszInstallDir
)
{
//这里写自己的特殊操作
}