我创建的Windows应用程序,我要开始我的应用程序在Windows启动时 为我写在下面安装程序类代码。但是当我使用注册表检查注册表我没有得到注册表值。和我的应用程序不工作。注册表启动不工作的Windows应用程序
public override void Commit(IDictionary savedState)
{
base.Commit(savedState);
try
{
RegistryKey add = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
add.SetValue("ToposcreenServer", "\"" + Application.ExecutablePath.ToString() + "\"");
RegistryKey key = Registry.LocalMachine.CreateSubKey(@"SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{70E25B31-99A9-474C-8990-CE28FBCEAAD1}", RegistryKeyPermissionCheck.Default);
if (key != null)
{
key.SetValue("SystemComponent", 1, RegistryValueKind.DWord);
key.Close();
}
Directory.SetCurrentDirectory(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));
Process.Start(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\ToposcreenServer.exe");
GLobalclass.WriteLog("Installer Executed");
}
catch (Exception ex)
{
GLobalclass.WriteLog("Installer Error :" + ex.Message);
}
}
你的代码设置两个注册表值。他们都没有设置? – mjwills
运行此代码时,什么是写入日志(“执行”或“错误”)? – mjwills