Link to home
Start Free TrialLog in
Avatar of nikola77
nikola77

asked on

RAS

How can I detect if there is any connection active ?
And how can I determinate it.........
Avatar of rwilson032697
rwilson032697

This code snippet appeared recently on EE:

function HangUpRAS: Integer;
const
  MaxConnections = 16;
var
  RAS: array[1..MaxConnections] of TRASCONN;
  BuffSize: DWORD;
  CONNSWritten: DWORD;
  i: Integer;
  Ret: DWORD;
begin
  Result := 0;
    { retrieve the number of Connections }
  RAS[1].dwSize := SizeOf(RAS[1]);
  BUFFSize := SizeOf(RAS);
  CONNSWritten := 0;
  Ret := RasEnumConnections(@RAS, BUFFSize, CONNSWritten);

  if (Ret = 0) or (Ret = ERROR_BUFFER_TOO_SMALL) then
    for i := 1 to CONNSWritten do
    begin
      if RashangUp(RAS[i].hrasconn) = 0 then Inc(Result);
    end;
end;

Additionally, there are some excellent RAS components and source code available at:

http://www.rtfm.be/fpiette/rasdialuk.htm 
and
http://www.bhnet.com.br/~simonet/extras/dialup.zip 

Cheers,

Raymond.

If you need a header for the RAS API (though one of the URLs I gave about _should_ contain it), you cn get it as a part of this component:

http://www.lexology.co.uk/delphi/other/files/tras.zip

Cheers,

Raymond.

Avatar of nikola77

ASKER

Undelclared identifier "TRASCONN"
????????
 

just add "ras" to the uses section of your unit.
raymond has given all you need ...
Or if your version of Delphi does not have the ras unit, use the RAS_API32.pas file from tras.zip file mentioned in my comment above.

Let me know when you have it working...

Cheers,

Raymond.
It's working now,
post me an answer rwilson.
Thanks...........

Cheers, nikola
ASKER CERTIFIED SOLUTION
Avatar of rwilson032697
rwilson032697

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks.