Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Monthly total time lapse for modem use

Posted on 1999-07-02
12
Medium Priority
?
166 Views
Last Modified: 2010-04-06
I have D4, Win98 and an external  modem. When my modem operates there is a modem function that times the connection.
It keeps track of  usage in hours, minutes, and seconds
for that single event.
 I want to make a total of this over the period of a month.
 I have already constructed a lapse timer that uses the functions for reading a  start time and end time, then a file record system keeps a grand total, but it is not connected to the modem.
 I need the  modem triggers that gives the start time,
end time and/or the lapse on that modem report in the first place.
I know there are free programs on the net that do this.

Delphi3
0
Comment
Question by:delphi3
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
12 Comments
 
LVL 15

Expert Comment

by:simonet
ID: 1385802
Do you use your modem with Internet (read Dial-up network) only or do you also need events like connecting to a BBS and the like?

If you need code for DUN/RAS only, I have the code you want.

Yours,

Alex
0
 
LVL 4

Author Comment

by:delphi3
ID: 1385803
Alex,
I use my computer in a dial up network mode only, I think. I don't have BBS,or I am not aware of what it is.

Thanks for the reply and question.
Delphi3
0
 
LVL 15

Expert Comment

by:simonet
ID: 1385804
Good... I'll be able to help you then.

A few months ago I started writing a project (never finished it) that would monitor my usage of Internet, so I could know how long I've been online, etc. The only part of the project I finished was getting the notification from the RAS system to when the modem is connected and disconnected from the Internet.

I can send you the curren project, with the part of the RasNotification stuff, which, I believe, can perfectly suit your needs.

Let me know your address so I can e-mail the project to you.

Yours,

Alex


0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 6

Expert Comment

by:Stuart_Johnson
ID: 1385805
Hi Alex,

Man, you must have a big 'bits basket' at your place.  Seems like you have an answer for anything DUN/RAS related.  Can I borrow your hard drive sometime <G>.

Stu.
0
 
LVL 15

Expert Comment

by:simonet
ID: 1385806
Hehehe! It's not like that, Stuart.

And yes, you may borrow my HD some time!

Alex
0
 
LVL 4

Author Comment

by:delphi3
ID: 1385807
Alex
 I am a security nut and do not wish to send my email
address to you in plain English.
But to help us communicate I have added
a security program in the previous program that you helped me
solve. See that progam in the comments section,
and form the program from the unit supplied
and the textonly part of the form. From these
you can make the program.
my email address in encrypted form is:

Mx$9a»RÝ„X„;k`òÉÐáÂ¥RM#.,Ùx†‘“0ÆoÜhø¼¦²GÚîiÃËö±ZxCL)ã¤I†æ6É+«½
0
 
LVL 15

Expert Comment

by:simonet
ID: 1385808
That's waaay too much trouble!

Here's what is easier: I've uploaded the whole project to my site. You can download it at:

http://www.bhnet.com.br/~simonet/extras/dialupspy.zip

Inside this zip archive, there's another zip file: rasnotify.zip, which contains exactly what you want.

Let me know how it went. If you still need me to mail it directly to you, my e-mail address is simonet@bhnet.com.br.

Yours,

Alex

0
 
LVL 4

Author Comment

by:delphi3
ID: 1385809
Alex,
I have downloaded and looked at your send  RasNotify and during launch the message of files 'not found' comes up. So nothing works infact the it just gets to a point that locks my computer up and I have to restart.

Elsewhere I found this in the FAQ's from Borland dated 12/98. This
 info expects that one has access to the Tcp1 and I do not have it. Yet this can be
 connected to a Delphi4 timer1 that will poll the local IP  '0.0.0.0' and as soon a change
happens then timing can begin using the computer's own time calculating system
and then continue to until  the  state of the IP goes back to  '0.0.0.0'


          Product    :All 32 bit  

          Question:
          How can I tell at runtime if I am connected to the internet?

          Answer:
          You can use the TCP component to retrieve the Local IP
          address. If it is "0.0.0.0" then there is no connection.

          Example:

          procedure TForm1.Button1Click(Sender: TObject);
          begin
            if TCP1.LocalIp = '0.0.0.0' then
              ShowMessage('Your not connected!');
          end;


          7/16/98 4:31:28 PM


           Trademarks & Copyright © 1998 INPRISE Corporation. Last modified on 8-December-1998.

Well , are we back to the starting point?  Any other bright ideas?

Delphi3
0
 
LVL 15

Expert Comment

by:simonet
ID: 1385810
What files does it say is missing? Have you tried the RasNotify.zip? That's where the notification stuff is.

As of Borland example's, it doesn't work too well because of the aspects below:

- If the computer is on a TCP/IP LAN, Borland's method will fail.
- If your connection to the internet is made through any other way othet than modem, it doesn't help you.

Here's the RAS NOTIFICATION stuff. It's wroking. Ubfortunatly, when a RAS notification is genereated, there's no way of knowing which RAS connection (RAS = dial up network under Win 9x) caused the notification and the nature of the notification (connection, disconnection, other party hung up, etc). Thus once the application receives that notification, it has to iterate through all the existing Dial Up connections in order to know which one suffered changes. This is what the rest of the code in the ZIP file does.

Here's the unit. The notification stuff works on a separate thread.


************* BOF

unit uRasThread;

interface

uses
  Classes;

type
  TRasThread = class(TThread)
  private
    { Private declarations }
  protected
    procedure Execute; override;
    procedure UpdateCaption;
  end;
{
type
  TRasConnection = class
  private
     FConnection : string;
     FStart      : TDateTime;
     FEnd        : TDateTime;
     FUser       : string;
     FProtocol   : string;

  public
     property
     constructor Create;
 }
implementation

uses Windows, SysUtils, Ras, umain2;


const
  RASCN_Connection       = $00000001;
  RASCN_Disconnection    = $00000002;
  RASCN_BandwidthAdded   = $00000004;
  RASCN_BandwidthRemoved = $00000008;

  function RasConnectionNotification(
  hrasconn: THRasConn;
  hEvent: THandle;
  dwFlags: Longint
  ): Longint; stdcall; forward;

function RasConnectionNotification;  external 'rasapi32.dll' name 'RasConnectionNotificationA';

{ Important: Methods and properties of objects in VCL can only be used in a
  method called using Synchronize, for example,

      Synchronize(UpdateCaption);

  and UpdateCaption could look like,


{ TRasThread }

procedure TRasThread.UpdateCaption;
var
      i : integer;
begin
      with form1 do
  begin
            for i:=0 to ListView1.items.count-1 do
              ListView1.Items[i].SubItems.Strings[4] := GetRASStatusString(GetRASHandle(ListView1.Items[i].caption));
  end;
//  Form1.button4.caption := 'RAS Event triggered';
//  beep;
//  beep;
  beep;
end;

procedure TRasThread.Execute;
var
  eventhandle : longint;
  x : dword;
begin
  eventhandle := CreateEvent(nil, false, false, 'RasNotifyEventObject');
  if eventhandle=0 then
     raise Exception.create('error in CreateEvent');

  if RasConnectionNotification(INVALID_HANDLE_VALUE, eventhandle, 2097151 {RASCN_Connection or RASCN_Disconnection})<>0 then
     raise Exception.create('error in RasConnectionNotification');

  x := WaitForSingleObject(eventhandle, INFINITE);
  while x=WAIT_OBJECT_0 do
  begin
     Synchronize(UpdateCaption);
     x := WaitForSingleObject(eventhandle, INFINITE);
  end;

end;

end.

********* EOF

Alex
Athena's Place: http://www.bhnet.com.br/~simonet


0
 
LVL 4

Author Comment

by:delphi3
ID: 1385811
Alex,
I have notified you by email  and  attached a .zip  to the email as a demo. Your sending me a program including some if not all of ras was significant. Please claim your points.
Thanks,
 
Delphi3  
0
 
LVL 15

Accepted Solution

by:
simonet earned 200 total points
ID: 1385812
Thank you very much, Bob, although I believe you did all of the work yourself.

I'll taking a look a the project you sent me and get back to you.

Good luck.

Alex
0
 
LVL 4

Author Comment

by:delphi3
ID: 1385813
Alex,
Thanks again.
Delphi3
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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…
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…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

715 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