摘要:
摘自:http://bbs.csdn.net/topics/380178685首先检测是否需要“以管理员身份运行”,如果需要程序重启并自动“以管理员身份运行”,用到如下两个方法: public static bool IsNeedRunAsAdmin() { //return true; //操作系统版本号6及以上,代表Vista/Win7以后的操作系统。 if (Environment.OSVersion.Version.Major >= 6) { ... 阅读全文
摘要:
摘自:http://greatverve.cnblogs.com/archive/2011/12/15/winform-path.htmlWinform获取应用程序的当前路径的方法集合,具体如下,值得收藏//获取当前进程的完整路径,包含文件名(进程名)。string str = this.GetType().Assembly.Location;result: X:\xxx\xxx\xxx.exe (.exe文件所在的目录+.exe文件名)//获取新的Process 组件并将其与当前活动的进程关联的主模块的完整路径,包含文件名(进程名)。string str = System.Diagnosti 阅读全文
摘要:
url:http://www.cnblogs.com/emanlee/archive/2009/08/31/1557380.html设置某程序随系统启动自动运行,取消自动运行。 使用到using Microsoft.Win32;名称空间。public void SetAutoRun(string fileName, bool isAutoRun) { RegistryKey reg = null; try { if (!System.IO.File.Exists(fileName)) throw new Except... 阅读全文