2013-10-10 91 views
0

我已經完成了Windows窗體應用程序的維護工作,該窗體應用程序包含Windows Form_Load窗體上的RegistryKey代碼。但是我不知道RegistryKey代碼正在執行哪些工作snippet.Here是我的代碼,這是令我費解的..RegistryKey在Windows窗體應用程序上執行的操作

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 \軟件\微軟\的Windows \ CurrentVersion \ Run中寫入並設置窗口要啓動的應用程序啓動。

相關問題