Delphi-Kylix
  Home arrow Delphi-Kylix arrow Page 2 - The Client for an Internet Access Control ...
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
DELPHI-KYLIX

The Client for an Internet Access Control Application
By: David Web
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 3
    2008-09-29

    Table of Contents:
  • The Client for an Internet Access Control Application
  • Small and Main Window
  • Disable Mouse and Keyboard Access
  • Retrieving the Workstation Name

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    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. 

    More Delphi-Kylix Articles
    More By David Web


     

    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...







    © 2003-2010 by Developer Shed. All rights reserved. DS Cluster 2 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek