delphi3000.com - the free delphi knowledge platform
delphi3000.com - the free delphi knowledge platform
Have a look at your member-status

connecting people's knowledge


  - Recent ArticlesRSS feed for Recent Articles on delphi3000.com
  - List of All Articles
  - Top Viewed Articles
  - Articles (+Attachem.)
  - Articles Of Interest
  - Categories
  - Top Uploader
  - Search
  - Index

  - My Home
  - Submit an Article
  - My Articles
  - My Personal Data
  - My Bookmarks
  - Activities
  - Login/Logout

  - Sign Up
  - Why Sign Up
  - Newsletter

  - Press
  - Advertise

  - Contact
  - Feedback



Community
Borland
ClubeDelphi
Dr. Bob
UK-BUG
Delphi Meetings
Planeta Delphi








Share this article with friendsShare this article with friends
Rate this articleRate this article - to keep the quality of delphi3000.com !
Comment this article or read through previous comments (6)


Building a Terminal Server Client-ApplicationGo to Max Kleiner's websiteFormat this article printer-friendly!Bookmark function is only available for registered users!
Working with MSTerminal Services Advanced Client ActiveX
Product:
Delphi 4.x (or higher)
Category:
ActiveX
Skill Level:
Scoring:
Last Update:
11/18/2002
Search Keys:
delphi delphi3000 article borland vcl code-snippet Terminal-Server Architecture Terminal-Services Terminal
Times Scored:
13
Visits:
12844
Uploader: Max Kleiner
Company: kleiner kommunikation
Reference: http://www.microsoft.com/windows2000/downloads/recommended/TSAC/tsmsi.asp?
 
Question/Problem/Abstract:
Even if a full Terminal Server Client is not installed on a user's computer or you want Server Apps embedded in Delphi applications, the ActiveX control (MSTSCAX) can be a great opportunity, let's see how it works.
Answer:



Since August 02 MS provides a new way to connect to a Terminal Server
called the MSTerminal Services Advanced Client (TSAC).
The TSAC is a Win32-based ActiveX control (COM object) that can be used
to run Terminal Services sessions within EXE's that interact with
applications running on a terminal server. The TSAC is an interim release of Terminal Services components and features. The purpose is to extend the functionality of Terminal Services, client side, so that system administrators, Web page designers, and Web administrators can implement Terminal Services client sessions in Web pages or Delphi applications without requiring the user to download or install the full Terminal Services client program.
These innovations greatly extend the usefulness of Terminal Services for remote administration of servers or server applications.

So how it works in Delphi?
---------------------------
When you install the ActiveX Client Control, a minimal set of sample Web pages is also installed on your Web server, but now we're interested only in a Delphi-application, which shows in a "bitmaplike" the Servers desktop or in our example an application that runs on a server!
Developers can use the TSAC to develop client-side applications that interact with applications running on a terminal server. MSTSCAX provides full control of Terminal Services user session.
The Client Control is an ActiveX control that provides virtually the same functionality as the full Terminal Services Client, but it is designed to deliver this functionality in a simple EXE or over the Web. When embedded in Delphi applications, the ActiveX control can host a client session with a Terminal server, even if the full Terminal Server Client is not installed on a user's computer.

Note:
In order to run the following application on another computer like NT or W98 you must copy "mstscax.dll" on the target and register it with regsvr32.


The Import of the Control
--------------------------
Further tests and coding with the control are made by Dmitry Arefiev and myself.
First of all we have to import the activeX control mstscax in Delphi
1. Download the TSMSISETUP.EXE (435kb) from

http://www.microsoft.com/windows2000/downloads/recommended/TSAC/tsmsi.asp?

2. run TSMSISETUP.EXE and it will install MSTSCAX into specified directory.
3. run REGSVR32.EXE \MSTSCAX.DLL and it will register the control on your machine, then run Delphi and import the control into Delphi (via ActiveX) and create a Unit.
4. Put the imported control from the palette to a form.

MSTSCAX is windowed control, which has 2 user session painting modes: Window mode. The window client region represents area, in which Terminal Server session will be painted.
Full Screen mode. Here will be created special window, which will cover all desktop area. And user session will be painted in this window, and not in MSTSCAX window client region.


The creating of the Client
-------------------------------
Now we create a Delphi project and first have a look at four interesting properties:

1. Server: type a Terminal server name or TCP\IP address or select a server from the list of Available servers.

Note: If you previously disconnected from a Terminal server without ending the session, the Terminal Services Client reconnects to that session (if the connection is configured for the reconnection of disconnected sessions).

2. Domain: Type your user name, password, and domain (if required), so it's the domain which user name belongs.

procedure TfrmMain.btnConnectClick(Sender: TObject);
var pathToRun: string[255];
begin
pathToRun:='C:\WINNT\system32\clock.exe';
  with TfrmTerminal.Create(Application) do begin
    MsTscAx1.Server := edtServer.Text;
    MsTscAx1.UserName := edtUserName.Text;
    MsTscAx1.Domain := edtDomain.Text;
    MsTscAx1.SecuredSettings.StartProgram := pathToRun;
    ....


3. BitmapPeristence: if we want to cache bitmaps set it to 1 (bitmaps stored on your local hard drive)

4. Compress: if we want to compress data set it to 1

procedure TfrmTerminal.FormCreate(Sender: TObject);
begin
  MsTscAx1.AdvancedSettings.BitmapPeristence := 1;
  MsTscAx1.AdvancedSettings.Compress := 1;
end;


After all with the connect method we open the terminal emulation session:

  MsTscAx1.Connect;

and with the disconnect method we close the connection-channel but session is not closed on the server. Therefore we must close the app on server by first closing the client application:

procedure TfrmTerminal.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  if not frmMain.btnConnect.enabled then begin
    messageDlg('close server app', mtInformation, [mbOK], 0);
  Action := caNone;
end;
end;

Then we receive onDisconnected so we can close the form:

procedure TfrmTerminal.MsTscAx1Disconnected(Sender: TObject;
  DisconnectReason: Integer);
begin
  Close;
end;


Benefits:
Full application is on the server. Then MSTSCAX may be used to setup and run user session on client computer. You can also split application into parts. Some parts will be located on server and some on client computer.
The MSTSCAX will be used to integrate parts into single application.


One last compile: the propertie BitmapPeristence, I mean it should written Persistence but a look at the wrapper shows BitmapPeristence ;):
//

*********************************************************************//
// DispIntf:  IMsTscAdvancedSettingsDisp
// Flags:     (4416) Dual OleAutomation Dispatchable
// GUID:      {809945CC-4B3B-4A92-A6B0-DBF9B5F2EF2D}
//

*********************************************************************//
  IMsTscAdvancedSettingsDisp = dispinterface
    ['{809945CC-4B3B-4A92-A6B0-DBF9B5F2EF2D}']
    property Compress: Integer dispid 121;
    property BitmapPeristence: Integer dispid 122;
    property allowBackgroundInput: Integer dispid 161;
    property KeyBoardLayoutStr: WideString writeonly dispid 162;
    property PluginDlls: WideString writeonly dispid 170;
    property IconFile: WideString writeonly dispid 171;
    property IconIndex: Integer writeonly dispid 172;
    property ContainerHandledFullScreen: Integer dispid 173;
    property DisableRdpdr: Integer dispid 174;
  end;








Please rate this article!
Skill level:
BeginnerExpert

Useful:
No!Very!

Overall rating:
PoorExcellent



Comments to this article
Write a new comment
Proxy for TSC
    Chris Chris (Jan 9 2006 1:07PM)

Is it possible to set proxy server to connect by TSC app?
Respond

RE: Proxy for TSC
Max Kleiner (Jan 9 2006 2:32PM)

Yes. If the TS is on the same side as the clients, included in the LAT, and clients access is by IP# or Netbios name, then it should all work.  The Proxy (and WSP Client) should not even enter into the mix.
For example both of those subnets' address ranges are in the proxy's LAT!
see more under google groups "tsc proxy"


Respond

Autologin ?
    Manfred Linner (Feb 3 2005 10:01PM)

This is a nice piece of code, but i wonder if it is possible to connect to WTS without typing the password manually. How can the password be handled so that i can enable Autologin ? Security would be ok in our environment.
Respond

RE: Autologin ?
Max Kleiner (Feb 4 2005 10:20AM)

For security reasons the Terminal Services Advanced Client (TSAC) ActiveX control does not provide interface for automatic password logon access to Terminal Servers using script . The only Method that provides such functionally is accessible through IMsTscNonScriptable Interface which is accessible only through custom-written container - for example Delphi/ Desktop application.

For additional information regarding this interface please see the
following URL:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/termserv/termserv/imstscnonscriptable_interface.asp

In addition there is one more IMsTscSecuredSettings  restricted interface that provides methods that  are restricted to specific Internet Explorer URL security zones.
But the TS Full Client is an example of this, you can pass the user login and password and it will login in automatically.
I did something like that some time ago. Based on the supposition that you are using the "default.htm" page supplied with the TSAC web site for remote admin, following are commands that you must add in your Web page.

(Add this command somewhere in the Body section)

(Add this command in the "BtnConnect" subroutine)
MsRdpClient.AdvancedSettings.ClearTextPassword =
UserPw.value




Respond

RE: RE: Autologin ?
Manfred Linner (Feb 4 2005 4:46PM)

Thanks for your answer. I checked MSDN library  for further information. Unfortunately i don't have deep skills in programming,  So would you please so kind to me give a snippet of sample code how to access the IMsTscNonScriptable interface ?
Kind regards, Manfred.
Respond

Nice Decision
    George (Nov 23 2002 11:32AM)

We just installed the service, so we don't had to produce a browser-version, the terminal-version is full operational
Respond














 
Sign up to consume product discounts for Bronze memberships !

read more


   


  Community Ad of
M. Maes
 
   














 







     
  Copyright © 2000 - 2007 delphi3000.com - All rights reserved. Terms of use. || Privacy
delphi3000.com is a service by bluestep.com IT-Services GmbH (Vienna)