Solved

DUN RasEnumConnections problem (please help!)

Posted on 2004-03-24
4
538 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
[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
  • 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

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!

Question has a verified solution.

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

This is an explanation of a simple data model to help parse a JSON feed
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

751 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