Solved

Internet Timer

Posted on 2001-06-13
8
168 Views
Last Modified: 2010-04-06
Can anyone help me with an internet timer ? It must create a log file with the start time, end time, total time and the total cost of the call. It must also take into account peak and offpeak hours.

It must also be in running at startup and monitor all connections and start the timer when anyone of the dialup accounts are activated.

Thank you
0
Comment
Question by:DigitalNam
8 Comments
 
LVL 8

Expert Comment

by:Cesario
ID: 6185532
Hi DigitalNam,

1) Place a Timer on your Form

2) some globale var...
   NewSession : Boolean;
   Startime   : DWORD;
   EndTime    : DWORD;
   StartDate  : TDateTime
   EndDate    : TDateTime;
   TotSec     : LongInt;

2) Detecting If You Have a Connection to the Internet
   http://support.microsoft.com/support/kb/articles/Q242/5/58.ASP

3) If you are connected
     - IF NewSession = False:
         NewSession := True;
         StartTime  := GetTickCount;
         StartDate  := Now;
                 
   IF Not
     - IF NewSessaion = TRUE
          EndTime := GetTickCount;
          EndDate := Now;
          TotSec  := (EndTime-StartTime) DIV 1000;
          NewSession := False;
          Calculate the costs
          Put this Data to you Database
           

4)  To Show the picks you can use a TChart


Best Regards

Cesario
0
 
LVL 8

Expert Comment

by:Cesario
ID: 6185542
sorry it was the rong link :-)

uses WinInet;  

procedure Connected:Boolean;
var
  dwConnectionTypes : DWORD;
begin
  dwConnectionTypes := 1; // Modem
  Result := InternetGetConnectedState(@dwConnectionTypes, 0)
end;
0
 
LVL 8

Accepted Solution

by:
Cesario earned 200 total points
ID: 6185556
another function to check if you are connected or not

uses wininet;

function Online(var Modem, LAN, Proxy, Busy : boolean) : boolean; //Testet: Internet connection vorhanden +Art ? // var
 flags : dword;
begin
  Result := InternetGetConnectedState(@flags, 0);
  if Result then
  begin
    if (flags and INTERNET_CONNECTION_MODEM) = INTERNET_CONNECTION_MODEM then
    begin
      Modem := True;
    end;
    if (flags and INTERNET_CONNECTION_LAN) = INTERNET_CONNECTION_LAN then
    begin
      LAN := True;
    end;
    if (flags and INTERNET_CONNECTION_PROXY) = INTERNET_CONNECTION_PROXY then
    begin
      Proxy := True;
    end;
    if (flags and INTERNET_CONNECTION_MODEM_BUSY)=INTERNET_CONNECTION_MODEM_BUSY then
    begin
      Busy := True;
    end;
  end;
end;
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
LVL 14

Expert Comment

by:AvonWyss
ID: 6185867
Cesario, goot hint with the Online function. However, it does not return what type of connection is to be used when the internet is not connected. And the MODEM_BUSY part is not used (as per MSDN, October 1999). So I'd implement your function like this:

function Online(var Modem, LAN, Proxy: Boolean): Boolean; //Testet: Internet connection vorhanden
var
     flags: Cardinal;
begin
     Result:=InternetGetConnectedState(@flags,0);
     Modem:=flags and INTERNET_CONNECTION_MODEM>0;
     LAN:=flags and INTERNET_CONNECTION_LAN>0;
     Proxy:=flags and INTERNET_CONNECTION_PROXY>0;
end;

DigitalNam, in case you like it, credits still go to Cesario for this code.
0
 

Expert Comment

by:DelFreak
ID: 6190010
Listening...
0
 
LVL 6

Expert Comment

by:edey
ID: 6418485
I would think there should be some points coming Cesario's way, no?


GL
Mike
0
 
LVL 1

Author Comment

by:DigitalNam
ID: 6419883
Not actually what I was looking for, but made me think in another way. Thanks.

PS: Bought source code from another author.
0
 
LVL 1

Author Comment

by:DigitalNam
ID: 6419886
Not actually what I was looking for, but made me think in another way. Thanks.

PS: Bought source code from another author.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question