Solved

Internet Timer

Posted on 2001-06-13
8
167 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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
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

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ddeman not working in activex 3 103
calling Tcolordialog in dll make the form disappear 8 111
Delphi Dbf export problem to a Visual Foxpro application 6 189
Delphi Yen format 3 35
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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

772 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