Solved

DUN RasEnumConnections problem (please help!)

Posted on 2004-03-24
4
536 Views
Last Modified: 2007-12-19
Hi experts,

I'm closing down on a long problem I've been having, I posted a few Q's in the Delphi area and now I'm posting here a second one cause its urgent, the matter is separated, the guys in the Delphi area  must be sick of me and also Dan pointed out something about posting two Qs in one so I guess it's ok to post many Qs if the subject is a bit different ;)

Anyway, my problem is as follows:
I have a small application to stablish a Dialup connection to a local ISP. It works fine, my problem is that in Win2000 & WinXP I can't disconect the dialing when the user clicks on my "cancel" button.

I'm using RasApi. I realized that my RasEnumConnections isn't returning connections so I can't call RasHangUp on it, I'm guessing...

All I wan't is to be able to cancel the connection I'm stablishing, at this point I'm really not concerned how.

What eventually happens is, since my code for disconnecting doesn't work, the connection ends up getting stablished succesfully eventhough the user had click the "cancel" button.

This is a link to another Q I posted in the Delphi area:
http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_20922613.html

Please help!

Thanks,

Esopo.
0
Comment
Question by:Esopo
  • 2
  • 2
4 Comments
 
LVL 10

Accepted Solution

by:
Kavar earned 300 total points
ID: 10673083
do you have a valid hrasconn handle?  (I mean can you RasGetConnectStatus without error?)

excerpt from msdn
*********************
When a RAS client application starts a connection operation, the RasDial call receives an HRASCONN connection handle to identify the connection. If the returned handle is not NULL, the client must eventually call the RasHangUp function to end the connection. If an error occurs during the connection operation, the client must call RasHangUp even though the connection was never established.

The application that calls RasHangUp should not exit immediately because the Remote Access Connection Manager needs time to properly terminate the connection. Instead, the application should wait until the RasGetConnectStatus function returns ERROR_INVALID_HANDLE, indicating that the connection has been deleted.
**********************
'end msdn


0
 
LVL 14

Author Comment

by:Esopo
ID: 10673427
Do you mean that, with the HRASCONN connection handle returned by RasDial, I can call RasHangUp even without getting valid connections from  RasEnumConnections?

I'm sure checking this up, thank you for your comment, if you have any other idea please let me know.

Best regards,

Esopo.
0
 
LVL 10

Expert Comment

by:Kavar
ID: 10673438
yes that is what I mean, if you can RasGetConnectStatus with your handle, then regardless of what enumconnections returns, you can RasHangUp the HRASCONN
0
 
LVL 14

Author Comment

by:Esopo
ID: 10682635
It seems to work like a charm. Of Course! the RasDial returns a Handle!! how could I have been so blind!

I stored the handle the RasDial returned and called RasHangUp with it. Seems to work properly. Thank you. This Q is over. (Finally, now I just have to close the other Qs related to this subject ;)
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …

860 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