代码如下:
private void InitializeRegis()
{
string fileName = Application.StartupPath;
RegistryKey rkey = Registry.LocalMachine;
RegistryKey rkey1 = rkey.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run", true);
rkey1.SetValue("ExcTol", fileName + @"\ExcelTol.exe");
rkey1.Close();
}
加入以下namespace{
string fileName = Application.StartupPath;
RegistryKey rkey = Registry.LocalMachine;
RegistryKey rkey1 = rkey.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run", true);
rkey1.SetValue("ExcTol", fileName + @"\ExcelTol.exe");
rkey1.Close();
}
using Microsoft.Win32;