private bool SetServiceAutoRun()
{
try
{
RegistryKey key =Registry.LocalMachine.OpenSubKey("SOFTWARE").OpenSubKey("Microsoft").OpenSubKey("Windows").OpenSubKey("CurrentVersion").OpenSubKey("Run",true);
key.SetValue("RoadService",Application.StartupPath + @"\MobileMessageControlCenter.exe");
return true;
}
catch
{
return false;
}
}
確實比較厲害
是在VB.NET中
我改了一點點
路徑那兒設不怎麼好
就寫死了
測試可行
Imports Microsoft.Win32
Private Function SetServiceAutoRun()
Try
Dim key As Microsoft.Win32.RegistryKey
key = Registry.LocalMachine.CreateSubKey("software\Microsoft\windows\CurrentVersion\Run")
key.SetValue("RoadService", "D:\Program Files\magicset\magicset.exe")
Return True
Catch ex As Exception
Return False
End Try
End Function