2013-10-10 3 views
0

У меня есть работа по обслуживанию приложения формы Windows, которое содержит код Windows RegistryKey в методе Form_Load формы. Но я не знаю, какая работа выполняется кодом RegistryKey сниппет .Здесь мой код, который озадачивает меня ..Что делает RegistryKey для Windows Form Application

try 
     { 
      RegistryKey rkStartUp = Registry.LocalMachine; 
      RegistryKey StartupPath; 
      StartupPath = rkStartUp.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run", true); 
      if (StartupPath.GetValue("ABCDXYZ") == null) 
      { 
       StartupPath.SetValue("ABCDXYZ", Application.ExecutablePath, RegistryValueKind.ExpandString); 
      } 
     } 
     catch 
     { 
     } 

Любая помощь, чтобы объяснить это будет высоко оценен.

ответ

5

Этот код просто сделать, как в комментарии

//gets the local machine registry settings 
    RegistryKey rkStartUp = Registry.LocalMachine; 
    RegistryKey StartupPath; 
    //opens the registry key in which all the windows startup applications are configured 
    StartupPath = rkStartUp.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run", true); 
    //checks if ABDXYZ application is in startup settings, if not exists as startup //app 
    if (StartupPath.GetValue("ABCDXYZ") == null) 
    { 
     //adds the startup app for ABCDXYZ, so that this application will start when windeos starts 
     //next time 
     StartupPath.SetValue("ABCDXYZ", Application.ExecutablePath, RegistryValueKind.ExpandString); 
    } 
0

Он просто открывает LocalMachine \ Software \ Microsoft \ Windows \ CurrentVersion \ Run для записи и устанавливает приложение, чтобы быть на окнах сумели запустить запуск.