如何将C#安装路径写入注册表

如何将C#安装路径写入注册表的提问

安装程序如将项目的安装路径写入注册表 如: 

  1. key =myform   
  2. value =E:\test\SystemTray\SystemTray.EXE 

如何将C#安装路径写入注册表的回答1

Value = [TARGETDIR]\后面是你的相对路径

如何将C#安装路径写入注册表的回答2

获取安装路径 

  1. string str = Assembly.GetExecutingAssembly().GetName().CodeBase;   
  2.                 if (str.ToLower().IndexOf("file:///") >= 0)   
  3.                 {   
  4.                     str = str.Substring(8, str.Length - 8);   
  5.                 }   
  6.                 string path = System.IO.Path.GetDirectoryName(str);//这个就是安装路径 

如何将C#安装路径写入注册表的回答3

在自定义操作中添加属性数据. 

  1. /dir=[TARGETVDIR] /targetdir="[TARGETDIR]\  
原文地址:https://www.cnblogs.com/swxj/p/2856078.html