Solved

Internet Timer

Posted on 2001-06-13
8
166 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

863 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

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now