您的位置:首页 > 其它

vc程序以管理员权限运行方法

2014-07-04 11:48 447 查看
由于刚刚做的小程序需要使用管理员权限运行,有时候运行的时候忘记了以管理员身份运行就无法看到正常的结果。为了让客户在运行的时候自动以管理员身份运行,百度一下,添加上管理员运行限制

方法一:

1找到VS2010的快捷方式:右击——“打开文件位置”

找到VS2010的启动项目devenv.exe:右击——属性——兼容性——特权等级,以管理员权限运行;如果需要每个用户都以管理员权限运行,还可以“更改所有用户的设置”——特权等级,以管理员权限运行。

然后在项目的打开方式中确保以VS2010为默认打开程序就好了。

2 属性--连接器--清单文件-》UAC执行级别-》requireAdministrator (/level='requireAdministrator')

方法二

清单文件:建立如app.mainfest的清单文件,在项目(属性--连接器--清单文件)添加清单文件

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>

<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">

<assemblyIdentityversion="1.0.0.0" processorArchitecture="X86" name="VistaLogoDemo" type="win32"/>

<description>Description of your application</description>

<!-- Identify the application security requirements.-->

<trustInfoxmlns="urn:schemas-microsoft-com:asm.v3">

<security>

<requestedPrivileges>

<requestedExecutionLevellevel="requireAdministrator" uiAccess="false"/>

</requestedPrivileges>

</security>

</trustInfo>

</assembly>

参考链接:http://blog.csdn.net/penglijiang/article/details/7178594
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: