Forwarding Mike Lucek's answer to this question, posted here a couple of
weeks ago:
----- Original Message -----
From: Mike Lucek
To:
Sent: 08 March 1999 14:27
Subject: Re:
I have replied to this question twice before, so if you were in the other
Delphi Talk list then there is some detailed stuff. However in summary, the
info you require is in the registry under HKEY_DYN_DATA PerfStats|StatData.
Call:
Dial-Up Adapater\Connect Speed To get connection speed
Dial-Up Adapter\Bytes Recvd How many bytes wre received
Dial-Up Adapter\Xmit How many bytes were sent
In addition there is some other interesting stuff there.
To get your timing, place a TTimer on your form and in the OnTimer event do
the
following:
var
NowTime : TDateTime;
begin
NowTime := Time - StartTime;
Label1.Caption := 'Duration: '+FormatDateTime('hhh:nn:ss',NowTime);
This will give progressive connection time, same as MS Status dilaog.
StartTime, is also a TDateTime and is set as soon as you have connected.
When you have disconnected, you can then capture the total time spent for
the current session, also cummulative time.
Mike Lucek
jnash@protek.co.uk wrote:
> Is there any way in delphi of telling how long you have been connected to
=
> the interent for through your browser? It'd be nice if I could find out
h=
> ow many byte etc has been transferred etc. Basivcally, I want to write a
=
> program that will automatically log the amount of time spent on the net.
=
> I'd like it to start automatically and finish automatically.=20=20
> Anyone got any ideas? or doen anything similar?
>
> Thanks
>
> Jamie
************************************
OR
The easiest way to find out if and how (proxy, ras...) you are connected to
the Internet,
without the overhead of installing components, is the following:
--> Snippet
USES
WinInet;
..
..
function InternetConnected: Boolean;
{
INTERNET_CONNECTION_MODEM = 1; // local system uses a modem to
connect to the Internet.
INTERNET_CONNECTION_LAN = 2; // local system uses a local area
network to connect to the Internet.
INTERNET_CONNECTION_PROXY = 4; // local system uses a proxy server to
connect to the Internet.
INTERNET_CONNECTION_MODEM_BUSY = 8; // local system's modem is busy with a
non-Internet connection.
}
VAR
dwConnectionTypes : DWORD;
BEGIN
dwConnectionTypes :=
INTERNET_CONNECTION_MODEM +
INTERNET_CONNECTION_LAN +
INTERNET_CONNECTION_PROXY;
Result := InternetGetConnectedState(@dwConnectionTypes,0);
END;
<-- Snippet
dwConnectiontype holds the appropriate flags after the call. This snippet
comes from
http://inner-smile.com/delphit2.htm