Go to my github

随笔分类 -  Win7开发系列

Win7开发系列
摘要: 一、安装服务:InstallService二、卸载windows服务:UnInstallService三、判断window服务是否存在:ServiceIsExistedprivateboolServiceIsExisted(stringserviceName){ServiceController[]services=ServiceController.GetServices();foreach(ServiceControllersinservices){if(s.ServiceName==serviceName){returntrue;}}returnfalse;四、启动服务:StartSer 阅读全文
posted @ 2011-07-12 18:38 峡谷少爷
摘要:我有一个应用程序需要检测是否正在升高的特权。我现在代码建立这样的: 函数功能 : 是否是管理员 private static bool _isAdministrator() { WindowsIdentity identity = WindowsIdentity.GetCurrent(); WindowsPrincipal principal = new WindowsPrincipal(identity); return principal.IsInRole (WindowsBuiltInRole.Administrator); } 类主要功能: 1:UAC状态查询 2:用户状态查询 public static class UacHelper { private const strin 阅读全文
posted @ 2011-07-04 10:42 峡谷少爷 阅读(836) 评论(0) 推荐(0)
摘要:问题: win7系统下,自己写了个windows服务,在cmd下运行installutil注册不成功,以管理员身份起动cmd后运行installutil注册成功。然后将服务卸载掉,另写了个程序用windowsAPI里的process函数调用installutil.exe去注册这个服务不成功,给出的提示是“......不可访问的日志: Security.........”,其实也就是权限问题。答案:方法如下: 在项目中新建一个文件:app.manifest,然后在其中输入以下代码,即可将该程序的运行权限提高到管理员级别。app.manifest内容如下:?xmlversion=" 阅读全文
posted @ 2011-07-02 13:00 峡谷少爷 阅读(2492) 评论(0) 推荐(1)