vc程式以管理員許可權執行方法
由於剛剛做的小程式需要使用管理員許可權執行,有時候執行的時候忘記了以管理員身份執行就無法看到正常的結果。為了讓客戶在執行的時候自動以管理員身份執行,百度一下,新增上管理員執行限制
方法一:
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