Home arrow Delphi-Kylix arrow Page 2 - The Client for an Internet Access Control Application
DELPHI-KYLIX

The Client for an Internet Access Control Application


Recently we finished a series covering the server side for an Internet access control application; now we're ready to take on the client. The client application is what the Internet users will see shortly before a workstation is activated or when a session is completed. It is responsible for both time and user access management as you will see in the rest of the series. Crucially, it is also responsible for processing all communication between itself and the server.

Author Info:
By: David Web
Rating: 5 stars5 stars5 stars5 stars5 stars / 6
September 29, 2008
TABLE OF CONTENTS:
  1. · The Client for an Internet Access Control Application
  2. · Small and Main Window
  3. · Disable Mouse and Keyboard Access
  4. · Retrieving the Workstation Name

print this article
SEARCH DEVARTICLES

The Client for an Internet Access Control Application - Small and Main Window
(Page 2 of 4 )

The client has two parts. The first part is what a user will see when a session has started. This includes a small window that will tell the user how much time she has left for her session. And the other is the main window that shows the ads.

In the source code for the client, Iíve set the ads window to cover the entire screen. But you can of course modify it to suit. Also, when the ads window is set, keyboard and mouse access will be disabled. This is because you do not expect anyone to use the workstation concerned, and the workstation will only be activated if a session has been started for it. Below is a listing of the main code for the client application:

Listing 1:


unit uclient;


interface


uses

Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

Dialogs, StdCtrls, Buttons,idsync,idcommandhandlers, IdBaseComponent,

IdComponent, IdTCPConnection, IdTCPClient, IdCmdTCPClient, OleCtrls,

SHDocVw,INIFiles, jpeg, ExtCtrls;


type

TReadingThread = class(TThread)

protected

FConn: TIdTCPConnection;

procedure Execute; override;

public

constructor Create(AConn: TIdTCPConnection); reintroduce;

end;

TLog = class(TIdSync)

protected

FMsg: String;

procedure DoSynchronize; override;

public

constructor Create(const AMsg: String);

class procedure AddMsg(const AMsg: String);

end;




TForm1 = class(TForm)

edname: TEdit;

btnConnect: TBitBtn;

btnDiscon: TBitBtn;

btnExit: TBitBtn;

tc: TIdCmdTCPClient;

one: TButton;

wb: TWebBrowser;

setof: TTimer;

procedure btnExitClick(Sender: TObject);

procedure tcConnected(Sender: TObject);

procedure btnDisconClick(Sender: TObject);

procedure btnConnectClick(Sender: TObject);

procedure tcDisconnected(Sender: TObject);

procedure oneClick(Sender: TObject);

procedure FormShow(Sender: TObject);

procedure FormCreate(Sender: TObject);

procedure Button1Click(Sender: TObject);

procedure FormActivate(Sender: TObject);

procedure setofTimer(Sender: TObject);

private

{ Private declarations }

public

{ Public declarations }

//this var will control mouse/keyboard access with timer

setoff:boolean;

function GetComputerName: string;

function FuncAvail(dllName, funcName: string; var p: pointer): boolean;

end;


var

Form1: TForm1;

rt: TReadingThread = nil;

path:string;

BlockInput : function(Block: BOOL): BOOL; stdcall;

implementation


uses utimer;


{$R *.dfm}

//***shutdown function

function TimedShutDown(Computer: string; Msg: string; Time: Word; Force: Boolean; Reboot: Boolean): Boolean;

var

rl: Cardinal;

hToken: Cardinal;

tkp: TOKEN_PRIVILEGES;

begin

//get user privileges to shutdown the machine

if not OpenProcessToken(GetCurrentProcess, TOKEN_ADJUST_PRIVILEGES or TOKEN_QUERY, hToken) then

ShowMessage('Cannot open process token.')

else

begin

if LookupPrivilegeValue(nil, 'SeShutdownPrivilege', tkp.Privileges[0].Luid) then

begin

tkp.Privileges[0].Attributes := SE_PRIVILEGE_ENABLED;

tkp.PrivilegeCount := 1;

AdjustTokenPrivileges(hToken, False, tkp, 0, nil, rl);

if GetLastError <> ERROR_SUCCESS then

ShowMessage('Error adjusting process privileges.');

end

else

ShowMessage('Cannot find privilege value.');

end;


Result := InitiateSystemShutdown(PChar(Computer), PChar(Msg), Time, Force, Reboot)

end;


//**end shutdown function


The shutdown function, as the name suggests, is responsible for shutting down a connected workstation. When the shutdown code is executed, a timed shutdown dialog box will appear on the workstation's screen. Finally, the computer will be shut down. 


blog comments powered by Disqus
DELPHI-KYLIX ARTICLES

- Loading an XML Document into the DOM
- Delphi Wrapper Classes and XML
- Delphi and the DOM
- Delphi and XML
- Internet Access: Client Service
- Finishing the Client for an Internet Access ...
- The Client for an Internet Access Control Ap...
- User Management for an Internet Access Contr...
- Important Procedures for an Internet Access ...
- Server Code for an Internet Access Control A...
- Constructing the Interface for an Internet A...
- Building a Server Application for an Interne...
- Building an Internet Access Control Applicat...
- Client Dataset: Working with Data Packets an...
- Using the Client Dataset in an N-Tiered Appl...

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 

Developer Shed Affiliates

 




© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials