using Microsoft.Win32;
| Код | private void myForm_Load(object sender, EventArgs e) { RegistryKey rgk; string[] subKeyNames; string strName, prName; int i = 0, iC; bool res = false; rgk = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run\", true); subKeyNames = rgk.GetValueNames(); iC = rgk.ValueCount; strName = Application.ExecutablePath; prName = Application.ProductName.ToString() + ".exe"; while(i < iC){ if(String.Compare(prName, 0, subKeyNames[i], 0, prName.Length, true) == 0) { res = true; } i++; } if(res == false) { rgk.SetValue(prName, strName); } rgk.Close(); }
|
|