1. 程式人生 > >vs2005和vs2010 UAC提權

vs2005和vs2010 UAC提權



UAC是什麼意思,看官方解釋:

User Account Control (UAC) is a new security component in Windows Vista and newer operating systems. With UAC fully enabled, interactive administrators normally run with least user privileges. This article and the attached code samples demonstrate these frequently asked coding scenarios related to UAC.

簡單來說就是給當前應用程式提供許可權,進而可以對系統做一些需要特殊許可權才能完成的操作,比如聯網,寫檔案等。

在VS2010下UAC提權非常簡單,只需要在編譯器內工程屬性設定即可,如下圖:

但vs2005就沒有這麼簡單了,但也是比較方便的,方法如下:

首先新建一個xml檔案,輸入以下下內容:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="requireAdministrator"/>
</requestedPrivileges>
</security>
</trustInfo>
</assembly>

然後將這個檔案拖拽到vs2005的工程目錄下,通過選單新增因為有file filter,似乎新增不了。

然後重新命名下檔案為 uac.manifest,重新編譯即可