使用winform将安装路径从winform传递到自定义操作

时间:2012-11-03 19:42:21

标签: c# winforms windows-installer

我正在尝试使用Windows窗体创建自定义Windows安装程序。 如何创建自定义操作,可以从Windows窗体接受安装路径进行安装。 我正在尝试将值从Windows窗体分配到this.Context.Parameters["targetdir"],但应用程序正在默认路径中安装,即C:\Program Files (x86)\Microsoft\Setup1

public override void Install(IDictionary savedState)
        {
            base.Install(savedState);
            const string key_path = "SOFTWARE\\VendorName\\MyAppName";
            const string key_value_name = "InstallationDirectory";

            RegistryKey key = Registry.LocalMachine.OpenSubKey(key_path, RegistryKeyPermissionCheck.ReadWriteSubTree);

            if (key == null)
            {
                key = Registry.LocalMachine.CreateSubKey(key_path);
            }
            this.Context.Parameters["targetdir"] = default_installation_path;
            string tgt_dir = this.Context.Parameters["targetdir"];
            key.SetValue(key_value_name, tgt_dir);
        }

请帮助我,我是安装人员的新手。

0 个答案:

没有答案