...Terminal Services entdecken?
Autor: P. Below
{
Question:
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
> );
>
}
type
OSVERSIONINFOEX = packed record
dwOSVersionInfoSize: DWORD;
dwMajorVersion: DWORD;
dwMinorVersion: DWORD;
dwBuildNumber: DWORD;
dwPlatformId: DWORD;
szCSDVersion: array[0..127] of Char;
wServicePackMajor: WORD;
wServicePackMinor: WORD;
wSuiteMask: WORD;
wProductType: BYTE;
wReserved: BYTE;
end;
TOSVersionInfoEx = OSVERSIONINFOEX;
POSVersionInfoEx = ^TOSVersionInfoEx;
const
VER_SUITE_TERMINAL = $00000010;
VER_SUITENAME = $00000040;
VER_AND = 6;
function VerSetConditionMask(
ConditionMask: int64;
TypeMask: DWORD;
Condition: Byte
): int64; stdcall; external kernel32;
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.
}
printed from
www.swissdelphicenter.ch
developers knowledge base