public static bool SetAutoRun(string keyName, string filePath)
{
try
{
RegistryKey runKey = Registry.LocalMachine.OpenSubKey(@"\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", true);
runKey.SetValue(keyName, filePath); //未将对象引用设置到对象实例 (报错)
runKey.Close();
}
catch (Exception err)
{
return false;
}
return true;
}
keyName="qq";
filePath="G:\xiao\qc\Bin\QQ.exe";
如可解决?谢谢
{
try
{
RegistryKey runKey = Registry.LocalMachine.OpenSubKey(@"\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", true);
runKey.SetValue(keyName, filePath); //未将对象引用设置到对象实例 (报错)
runKey.Close();
}
catch (Exception err)
{
return false;
}
return true;
}
keyName="qq";
filePath="G:\xiao\qc\Bin\QQ.exe";
如可解决?谢谢
解决方案 »
- 想在winForm中通过点击按钮打开.txt文件,真心求教,谢过~~~~~~~~~
- DevExpress与devcomponents是什么关系
- 求助各位高手:gdi+绘图,编写一个折线图控件(急)
- 由这些连接属性指定的SQL服务器不支持托管对象。请选择其他服务器。
- 多线程使用应该注意的问题!
- 将四个byte数据转成一个float型数据? 高手请进
- Request.Cookies不能枚举
- c#中不带任何控件的表格中如何显示数据库中的记录
- 请问vb里的picture1.ScaleHeight在C#里变成什么了?
- C# SDK文档 是什么??[在线等待]
- 急需求助..c#如何在摄像头的预览画面的时候如何画矩形(即矩形一直在视频摄像时候一直存在)
- C#正则表达式的问题,很简单,忘高手简答一些
啊,,,是 null,,,,
(@"\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", 是这 写错了 ?
改成
RegistryKey runKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run", true); 多了一个\符