Solved

DUN RasEnumConnections problem (please help!)

Posted on 2004-03-24
4
533 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
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 …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

771 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now