Mega Code Archive

 
Categories / Delphi / LAN Web TCP
 

How to build a Terminal Services Client

Title: How to build a Terminal Services Client unit Main; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, OleCtrls, ExtCtrls, StdCtrls, MSTSCLib_TLB;//the import Unit: substitute it with the name you assigned //during the import process if this is different to it type TForm1 = class(TForm) MsTscAx1: TMsTscAx; Panel1: TPanel; btConnect: TButton; procedure btConnectClick(Sender: TObject); //connection button procedure FormCreate(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure MsTscAx1Disconnected(Sender: TObject; DisconnectReason: Integer); procedure MsTscAx1Connecting(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.DFM} procedure TForm1.btConnectClick(Sender: TObject); begin MsTscAx1.Connect; end; procedure TForm1.FormCreate(Sender: TObject); begin Left := 0; Top := 0; Height := Screen.Height - 20; Width := Screen.Width; MsTscAx1.Server := '1.2.3.4'; //substitute it with the IP Address of your server with MsTscAx1.AdvancedSettings do begin BitmapPeristence := 1;//enable bitmap cache Compress := 1;//enable data cache end; with MsTscAx1.SecuredSettings do begin Set_StartProgram('C:\Sviluppo\Delphi\DbBrowser.exe'); //the program I want to run end; end; procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction); begin if not btConnect.Enabled then //I must close the automatically running program before closing //my terminal emulation program begin MessageDlg('Close "DbBrowser.exe" before closing the application!', mtInformation, [mbOK], 0); Action := caNone; end; end; procedure TForm1.MsTscAx1Disconnected(Sender: TObject; DisconnectReason: Integer); begin btConnect.Enabled := True; end; procedure TForm1.MsTscAx1Connecting(Sender: TObject); begin btConnect.Enabled := False; end; end. In order to run this application in another computer you must copy the file ??mstscax.dll?? on the target computer and register it with ??regsvr32?? as shown at the beginning of this article. You can automate this process by embedding the file in your executable, etc.. Carlo Pasolini, Riccione, ccpasolini@libero.it