Snippet below can be used to programmatically determine if User Account Control is enabled:
objectpascal
Download
uses
JwaWinbase, JwaWinNt;
function IsUACEnabled: Boolean;
var
hToken: THandle;
tet: TOKEN_ELEVATION_TYPE;
dwSize: DWORD;
begin
Win32Check(OpenProcessToken(GetCurrentProcess, TOKEN_QUERY, hToken));
// TokenElevationType class only available on Vista+
Win32Check(GetTokenInformation(hToken, TokenElevationType, @tet, SizeOf(tet), dwSize));
Result := tet <> TokenElevationTypeDefault;
end;
[...] specified logon session does not exist. It may already have been terminated.”So you should check if User Account Control is enabled in such cases (or make this error non critical).share: Bookmark on Delicious Digg this post [...]