public static bool userStar(string strName)
{
try
{
if (!File.Exists(strName))
{
return true;
}
string strnewName = strName.Substring(strName.LastIndexOf("//") + 1);
RegistryKey RKey = Registry.LocalMachine.OpenSubKey("SOFTWARE//Microsoft//Windows//CurrentVersion//Run", true);
if (RKey == null)
{
RKey = Registry.LocalMachine.CreateSubKey("SOFTWARE//Microsoft//Windows//CurrentVersion//Run");
}
RKey.SetValue(strnewName, strName);//通过修改注册表,使程序在开机时自动运行
return true;
}
catch
{
return false;
}
}