Solved

DUN RasEnumConnections problem (please help!)

Posted on 2004-03-24
4
537 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

Technology Partners: 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

Suggested Solutions

Title # Comments Views Activity
Base1 Encode/Decode 3 85
Apps blocked by Java 9 96
Restore Windows 7 Snipping Tool function to Windows 10 10 93
Visual Studio hangs on running project 6 56
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.
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 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…

713 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