在Vista操作系統中通過manifest文件使VC應用程序獲得管理員權限

這是我在項目中遇到的,項目中的服務器在VC2005和XP環境下開發的,沒有加MANIFEST文件,使得在VISTA下當服務器時出現外面的客戶端無法訪問的問題,問我師傅,才知道是要添加manifest文件來使得VC應用程序獲得管理員權限,(*^__^*) 嘻嘻

問題也就解決了。

1.打開應用程序的源代碼工程

2.添加一個“custom”資源,"resource type"填24,把資源ID改爲1,然後把以下內容複製到資源內容中保存爲一下內容

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity
  version="1.0.0.0"
  processorArchitecture="X86"
  name="mulitray.exe.manifest"
  type="win32"
/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
  <security>
    <requestedPrivileges>
        <requestedExecutionLevel level="requireAdministrator" uiAccess="false"/>
    </requestedPrivileges>
  </security>
</trustInfo>
</assembly>

 

3.重新編譯應用程序就OK了

 

注意以上xml複製下來如果有中文標點符號要改成英文的標點符號,要不會提示 "並行配置錯誤"。

 

參考於:http://www.debugman.com/read.php?tid=325

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章