你用的是VS自带的安装还是自己写的?
可以自己写一个winform的安装程序 读注册表
可以自己写一个winform的安装程序 读注册表
解决方案 »
- 怎样在状态栏中显示突出显示的菜单项的说明信息?
- (C#)已经获取到窗体句柄,怎么向该窗体发送快截键消息呢?
- [C#] 怎么重启本机
- TreeView.SelectedNode怎么没有Depth这个属性啊。(WinForm)
- 如何根据ProcessCmdKey方法的Message参数获取消息源的类型?
- 再请教DataTable的InputRow时怎么控制自动增加列的问题
- 当我记录有9条时,?????
- 我想学C#……………………………………………………………………………………!
- 枚举型变量如何作为参数传递?
- 小弟用C#写了个系统进程管理系统。代码我现在发到网上了。需要的可以下。
- 如何实现鼠标拖动曲线并且拟合出公式
- 音乐播放器调用Ctlcontrols.play();用户代码未处理InvalidCastException
重写安装类相应的方法,比如安装前BeforeInstall方法读取注册表即可
http://www.cnblogs.com/yuanwoneng/archive/2009/07/10/1520291.html
用VS自带的打包程序,安装的时候,你的程序根本还没有运行,研究个什么劲,有什么用
用VS自带的打包程序,安装的时候,你的程序根本还没有运行,研究个什么劲,有什么用我的程序已经运行了,我现在每次覆盖安装还是需要重新选择安装路径
而你要安装的,是程序B
虽然他俩是同一个程序的升级版本,但是你不在打包的时候配置好,电脑可不知道他俩是一个东西你安装程序B的时候,程序A运行有什么用啊,程序A去修改程序B的安装路径?
你覆盖安装的时候,不先退出A,能覆盖?
而程序B,还在压缩包里呢,它能自己运行?
运行的不过是打包程序而已
对,我就是要在打包的时候配置,我在网上查资料this.Context.Parameters["targetdir"]这个是可以实现的,但是我这句代码是加到哪里,我打包程序的自定义操作里也添加了/targetdir="[TARGETDIR]\"
虽然我也不知道VS的打包怎么配置(我都是用第三方打包,不用VS自带的打包)
但是我知道,你的这个this.Context.Parameters["targetdir"]代码,只有程序运行时才好用,跟安装过程一点关系都没有
regSubKey.GetValue("path").ToString();
前面那些添加自定义步骤可以跳过,直接看添加安装类,然后重写
http://www.cnblogs.com/sunrack/articles/944153.html
http://msdn.microsoft.com/zh-cn/library/system.configuration.install.installer.aspx利用BeforeInstall事件或重写方法,读取注册表值并设置targetDir参数
private void InstallerTest_BeforeInstall(object sender, InstallEventArgs e)
{
string strPathResult = string.Empty;
string strKeyName = "";
object objResult = null; Microsoft.Win32.RegistryValueKind regValueKind;
Microsoft.Win32.RegistryKey regKey = null;
Microsoft.Win32.RegistryKey regSubKey = null;
string softName = "Stephen";
try
{
//Read the key
regKey = Microsoft.Win32.Registry.LocalMachine;
regSubKey = regKey.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths" + softName.ToString() + ".exe", false); //Read the path
objResult = regSubKey.GetValue("Path").ToString();
regValueKind = regSubKey.GetValueKind(strKeyName); //Set the path
if (regValueKind == Microsoft.Win32.RegistryValueKind.String)
{
strPathResult = objResult.ToString();
// this.Context.Parameters["targetdir"] = strPathResult;
}
}
catch (System.Security.SecurityException ex)
{
throw new System.Security.SecurityException("You have no right to read the registry!", ex);
}
catch (Exception ex)
{
throw new Exception("Reading registry error!", ex);
}
finally
{ if (regKey != null)
{
regKey.Close();
regKey = null;
} if (regSubKey != null)
{
regSubKey.Close();
regSubKey = null;
}
}
}
我已经把读取注册表写到这个事件里了,但是还是不管用呢,customactiondate属性我也设置成/targetdir="[TARGETDIR]\"