
- 积分
- 0
- 在线时间
- 1 小时
- 主题
- 0
- 注册时间
- 2016-3-31
- 帖子
- 2
- 最后登录
- 2017-2-19

- 帖子
- 2
- 软币
- 82
- 在线时间
- 1 小时
- 注册时间
- 2016-3-31
|
发表于 2017-2-19 01:29:48
|
显示全部楼层
void RegRun(string appName,bool f)
{
RegistryKey HKCU = Registry.CurrentUser;
RegistryKey Run = HKCU.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run", true);
bool b = false;
foreach (string i in Run.GetValueNames())
{
if (i == appName)
{
b = true;
break;
}
}
try
{
if (f)
{
Run.SetValue(appName, Application.ExecutablePath);
}
else
{
Run.DeleteValue(appName);
}
}
catch
{ }
HKCU.Close();
}
|
|