Link to home
Start Free TrialLog in
Avatar of Esopo
EsopoFlag for United States of America

asked on

RasHangup serious problem, pls help!!

Hi experts,

I'm having problems trying to disconnect a RAS connection I connected (or asked to connect) in WinXP (guess Win2000 too but not sure, have to run some tests).

The program I'm making connects a dial-up correctly and then closes, but if I try to cancel the process while connecting RasHangUp returns a non-zero value and the connection stays "open" in a "Disconnecting" stage.

I've been so frustrated with this I'm about to leave my carrer behind and get a job at a local Mc Donalds.

Please help!!  -- thanks!

Esopo.


BTW: this is related to my recent two other posts about Ras, I'm also working with that at the moment.
Avatar of shaneholmes
shaneholmes

try iterating the connections and hangup any connection still connected

var
  RasConn  : TRasConn;
  bsize    : DWORD;
  Count    :  DWORD;
begin
  RasConn.dwSize := SizeOf(TRasConn);
  bsize := SizeOf(RASConn);
  if RASEnumConnections(@RASConn, bsize, Count) = 0 then
     if Count > 0 then RASHangUp(RASConn.hRasConn);
end;

Shane
Avatar of Esopo

ASKER

I'll try that, but I don't think it solves my problem. The thing is RasHangUp ain't working like it should, so I don't see how disconnecting any other connection would do any good, besides, even if that worked I can't kill every connection the machine has just to take care of mine...
Avatar of Esopo

ASKER

I tried this idea out, and realized something strange, my RASEnumConnections isn't returning connections...
I don't know how this can be, this is my code:

 var
    hRas: THRasConn;
    bufsize: Longint;
    numEntries: Longint;
    entries: Array[1..100] of TRasConn;
    stat: TRasConnStatus;

  begin

  entries[1].dwSize := SizeOf(TRasConn);
  bufsize := SizeOf(TRasConn) * 100;
  FillChar(stat, Sizeof(TRasConnStatus), 0);
  stat.dwSize := Sizeof(TRasConnStatus);
  if RasEnumConnections(@entries[1], bufsize, numEntries) = 0 then...


It returns numEntries=0.  So I can't call rasHangUp on it, or can I ?

Just to make sure I make sense, this happens when I'm trying to disconnect the connection I'm dialing (when the user clicks cancel while connecting). Of course since I can't get connections enumerated I can't call RasHangUp on anything and the dialing just goes on until finally connected.

Everything else seems to be working fine.

Any suggestion will be highly appreciated.

Best regards,

Esopo.
Avatar of Melih SARICA
change the variable types to LPDword ..
    bufsize: PDWORD;
    numEntries: PDWORD;

   or
   bufsize: DWORD;
    numEntries: DWORD;
in the function usage use it with dword(@bufsize)

change the variable types to LPDword ..
    bufsize: PDWORD;
    numEntries: PDWORD;

   or
   bufsize: DWORD;
    numEntries: DWORD;
   in the function usage use it with @bufsize



Avatar of Esopo

ASKER

I eventually found a solution to this, I'm asking for this Q to be deleted.

Thank you ayway.

Esopo.
ASKER CERTIFIED SOLUTION
Avatar of GhostMod
GhostMod
Flag of United States of America image

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