Solved

Internet Timer

Posted on 2001-06-13
8
165 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Expert Comment

by:DelFreak
Comment Utility
Listening...
0
 
LVL 6

Expert Comment

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


GL
Mike
0
 
LVL 1

Author Comment

by:DigitalNam
Comment Utility
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
Comment Utility
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

744 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

19 Experts available now in Live!

Get 1:1 Help Now