문제

How do I request Administrator privileges during runtime so the user is given the prompt to allow or disallow it?

도움이 되었습니까?

해결책

This information is written in the exe file manifest. You must use the requestedExecutionLevel field (but not sure about that - try setting it to highestAvailable and see if it does what you need). See for example here for more information (somewhat older article but still valid): http://blogs.msdn.com/b/cjacks/archive/2006/09/08/exploring-manifests-part-2-default-namespaces-and-uac-manifests-in-windows-vista.aspx

There are tools in Visual Studio which allow you to embed your own manifest or even just edit it. Also there is a tool written in Perl ( http://metacpan.org/pod/Win32::Exe::Manifest ).

EDIT: see this article for more info: http://www.codeproject.com/Articles/66259/Requesting-Admin-Approval-at-Application-Start.aspx

다른 팁

if you want it in response to a button (eg, like 'show processes for all users' in task manager), you have to resart your app using the following method

ShellExecute(0,L"runas",exepath,0,0,SW_SHOWNORMAL);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top