如果想你写的程序随系统开机一起启动的话,那么你可以照下面这个方法来做。
runwhenstart(false, application.productname, application.startuppath + @\"\\mus.exe\");
/// <summary> /// 开机启动项 /// </summary> /// <param name=\"started\">是否启动</param> /// <param name=\"name\">启动值的名称</param> /// <param name=\"path\">启动程序的路径</param> public static void runwhenstart(bool started, string name, string path) { registrykey hklm = registry.localmachine; registrykey run = hklm.createsubkey(@\"software\\microsoft\\windows\\currentversion\\run\"); if (started == true) { try { run.setvalue(name, path); hklm.close(); } catch (exception err) { messagebox.show(err.message.tostring(), \"mus\", messageboxbuttons.ok, messageboxicon.error); } } [page] else { try { run.deletevalue(name); hklm.close(); } catch (exception) { // } } }
如对本文有疑问, 点击进行留言回复!!
C# 对PDF文档加密、解密(基于Spire.Cloud.SDK for .NET)
Unity通用泛型单例设计模式(普通型和继承自MonoBehaviour)
网友评论