Do you happen to have a sample piece of code for detecting if Terminal
Services is loaded? I found this piece of C code, but I'm having a hard
time translating things...
}
function IsRemoteSession: Boolean; const sm_RemoteSession = $1000; { from WinUser.h } begin Result := (GetSystemMetrics(sm_RemoteSession) <> 0); end;
{
That tells you if your program is running in a terminal client session,
which is usually all you ever need to worry about.
}
{
>
> #include <windows.h>
> #include <stdio.h>
>
> // This code will only work on the Windows 2000 platform
>
> BOOL IsTerminalServicesEnabled(void)
> {
> OSVERSIONINFOEX osVersionInfo;
> DWORDLONG dwlConditionMask = 0;
>
> ZeroMemory(&osVersionInfo, sizeof(OSVERSIONINFOEX));
> osVersionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
> osVersionInfo.wSuiteMask = VER_SUITE_TERMINAL;
>
> VER_SET_CONDITION( dwlConditionMask, VER_SUITENAME, VER_AND );
>
> return VerifyVersionInfo(
> &osVersionInfo,
> VER_SUITENAME,
> dwlConditionMask
> );
>
}
function VerifyVersionInfo( var VersionInformation: OSVERSIONINFOEX;
dwTypeMask: DWORD;
dwlConditionMask: int64
): BOOL; stdcall; external kernel32 name 'VerifyVersionInfoA';
function IsTerminalServicesEnabled: Boolean; var osVersionInfo: OSVERSIONINFOEX;
dwlConditionMask: int64; begin FillChar(osVersionInfo, SizeOf(osVersionInfo), 0);
osVersionInfo.dwOSVersionInfoSize := sizeof(osVersionInfo);
osVersionInfo.wSuiteMask := VER_SUITE_TERMINAL;
dwlConditionMask := 0;
dwlConditionMask :=
VerSetConditionMask(dwlConditionMask,
VER_SUITENAME,
VER_AND);
Result := VerifyVersionInfo(
osVersionInfo,
VER_SUITENAME,
dwlConditionMask); end;
{
But heed the warning in the C sample: the functions used here are not
available on Win 9x and NT 4! If you use external declarations as above
your program would not even load on such a platform.
}