CJC Delphi 技巧馆's Archiver

cjc Posted at 2018-9-20 10:34

Check UAC virtualization enabled

UAC virtualization enabled


// Gets whether the current process has UAC virtualization enabled.
// Returns TRUE on success and FALSE on failure.
function GetVirtualizationEnabled(var enabled:Boolean):Boolean;
var
  token:THandle;
  tmpEnabled:DWORD;
  returnLen:DWORD;
begin
  result:=false;
  enabled:=false;
  if not(OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, token)) then exit;
  try
    if not(GetTokenInformation(token, TokenVirtualizationEnabled,
              @tmpEnabled, sizeof(tmpEnabled), returnLen)) then exit;

    enabled:=tmpEnabled<>0;
    result:=true;
  finally
    CloseHandle(token);
  end;
end;


procedure showvar(v: boolean);
begin
   if v then
     showmessage('true')
  else
     showmessage('false')
end;

procedure TForm3.Button1Click(Sender: TObject);
var a: boolean;
begin
  a := false;
  if GetVirtualizationEnabled(a) then
     showvar(a)
  else
     showmessage('FAIL');

end;


// http://stackoverflow.com/questions/14005081/how-to-detect-file-redirection-to-the-windows-virtualstore

Page: [1]
CJC好玩背单词最新版本 - 是目前最好的背单词软件,游戏好玩,功能强大,词库众多,还有真人语音,免费下载,免费试用 !

Powered by Discuz! Archiver 6.1.0  © 2001-2007 Comsenz Inc.