Visual Studio 2005で、アプリケーション起動時にUACの昇格ダイアログを表示させる方法。
(Visual Studio 2008ならもっと簡単。)
Step 6: Create and Embed an Application Manifest (UAC)
Professional Visual Studio » Enabling Your Application for UAC
yourapp.exe.manifest
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> <ms_asmv2:trustInfo xmlns:ms_asmv2="urn:schemas-microsoft- com:asm.v2"> <ms_asmv2:security> <ms_asmv2:requestedPrivileges> <ms_asmv2:requestedExecutionLevel level="requireAdministrator"> </ms_asmv2:requestedExecutionLevel> </ms_asmv2:requestedPrivileges> </ms_asmv2:security> </ms_asmv2:trustInfo> </assembly>
post build task in your Visual Studio project's Project Properties:
"$(FrameworkSDKDir).\Bin\mt.exe" -nologo -manifest "$(ProjectDir)$(TargetFileName).manifest" -outputresource:$(TargetPath);#1"
or
mt.exe -manifest "$(ProjectDir)$(TargetName).exe.manifest" -updateresource:"$(TargetDir)$(TargetName).exe;#1"