for delphi,
I want to run my application with admin rights on vista or w开发者_JS百科in 7 is there a solution for this you may know ?
related question:
Want to learn if my application has admin rights?
thanks.
To run a program with admin rights I have this function which has worked for me so far.
procedure RunAsAdmin(const aFile: string; const aParameters: string = ''; Handle: HWND = 0);
var
sei: TShellExecuteInfo;
begin
FillChar(sei, SizeOf(sei), 0);
sei.cbSize := SizeOf(sei);
sei.Wnd := Handle;
sei.fMask := SEE_MASK_FLAG_DDEWAIT or SEE_MASK_FLAG_NO_UI;
sei.lpVerb := 'runas';
sei.lpFile := PChar(aFile);
sei.lpParameters := PChar(aParameters);
sei.nShow := SW_SHOWNORMAL;
if not ShellExecuteEx(@sei) then
RaiseLastOSError;
end;
精彩评论