开发者

How do I discover the image-quality settings of a Remote Desktop session?

I am using DevExpress skins. I implemented a switch to disable skins manually. I need this basically because of a Terminal server (I need to have a flat look to save on connection bandwith).

Anyway, the manual switch isn't good because the user must continously use it when using the application locally or remotely. Of course only a user who cares about look.

I would like to leave the manua开发者_如何学Gol switch but to add also another automatic switch that checks the Windows settings for performance (I don't know how to tell this in English, anyway, I mean that setting for performance that lets any version of Windows look, like Windows '98). I would like (if it is possible) to have a unique function that works on every Windows version (2K, XP, Vista, 7, and the server counterparts).

Please note I am not interested in merely knowing whether my system is running in RDP, but whether the performance settings are set for high image quality or not.


You can use my JwaWinsta unit which is in the Delphi Jedi Apilib.

More specifically you can use WinStationQueryInformationW with the WinStationClient info class which returns a WINSTATIONCLIENT structure.

In this structure is the WinStationClientFlags member which is a bitfield that can contain any mask of the following constant:

  TS_PERF_DISABLE_NOTHING = $0;
  TS_PERF_DISABLE_WALLPAPER = $1;
  TS_PERF_DISABLE_FULLWINDOWDRAG = $2;
  TS_PERF_DISABLE_MENUANIMATIONS = $4;
  TS_PERF_DISABLE_THEMING = $8;
  TS_PERF_ENABLE_ENHANCED_GRAPHICS = $10;
  TS_PERF_DISABLE_CURSOR_SHADOW = $20;
  TS_PERF_DISABLE_CURSORSETTINGS = $40;
  TS_PERF_ENABLE_FONT_SMOOTHING= $80;
  TS_PERF_ENABLE_DESKTOP_COMPOSITION = $100;
  TS_PERF_DEFAULT_NONPERFCLIENT_SETTING = $40000000;
  TS_PERF_RESERVED1 = $80000000;

Further more this structure also returns the ColorDepth member.


Use the SM_REMOTESESSION System Metric to determine if your program is running over RDP.

This OldNewThing post has much more information.


Hi You can use WTSEnumerateSessions api to check if the user is running in rdp mode.

var pSessionInfo: PWTS_SESSION_INFOW;
SessionInfo: WTS_SESSION_INFO;
SessionCount: Cardinal;
i: Integer;
begin
  try
    Result := -1;
    if WTSEnumerateSessions(WTS_CURRENT_SERVER_HANDLE, 0, 1, pSessionInfo, SessionCount) then
      begin
        SessionInfo := pSessionInfo^;
        for i := 0 to SessionCount - 1 do
          begin
            if SessionInfo.State = WTSActive then
              begin
                if Pos('rdp', LowerCase(SessionInfo.pWinStationName)) <> 0 then
                  ShowMessage('this is rdp');
              end;
            pSessionInfo := PWTS_SESSION_INFOW(Pointer(Integer(pSessionInfo) + SizeOf(WTS_SESSION_INFOW)));
            SessionInfo := pSessionInfo^;
          end;
      end;
  finally
    WTSFreeMemory(PSessionInfo);
  end;

Hope this answers your question. BTW delphi doesn't have an import for WTSEnumerateSessions, so you will have to import it by hand, or download a Jwa library. The function is decalred in JwaWtsApi32.pas


// returns the color bit depth (8, 16, 32, ....) on the machine
// note: it works also for rdp (it returns the color bit depth of
// the current session, not some default settings on the server)
function GetBitColorDepth: integer;
var
  DC: THandle;    // display context
begin
  DC := GetDC(HWND(nil));
  Result := GetDeviceCaps(DC, BITSPIXEL);
  ReleaseDC(HWND(nil), DC);
end;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜