was ist neu ¦  programmier tips ¦  indy artikel ¦  intraweb artikel ¦  informationen ¦  links ¦  interviews
 sonstiges ¦  tutorials ¦  Add&Win Gewinnspiel

Tips (1541)

Dateien (137)
Datenbanken (90)
Drucken (35)
Grafik (114)
IDE (21)
Indy (5)
Internet / LAN (130)
IntraWeb (0)
Mathematik (76)
Multimedia (45)
Oberfläche (107)
Objekte/
ActiveX (51)

OpenTools API (3)
Sonstiges (126)
Strings (83)
System (266)
VCL (242)

Tips sortiert nach
Komponente


Tip suchen

Tip hinzufügen

Add&Win Gewinnspiel

Werbung

29 Visitors Online


 
...Terminal Services entdecken?
Autor: P. Below
[ Tip ausdrucken ]  

Tip Bewertung (7):  
     


{
 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; stdcallexternal kernel32;

function VerifyVersionInfo(
  var VersionInformation: OSVERSIONINFOEX;
  dwTypeMask: DWORD;
  dwlConditionMask: int64
  ): BOOL; stdcallexternal 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.
}


 

Bewerten Sie diesen Tipp:

dürftig
ausgezeichnet


Copyright © by SwissDelphiCenter.ch
All trademarks are the sole property of their respective owners