• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 311
  • Last Modified:

How to close FTP connection using INET control?

I'm transferring some files through a dial-up Connection (FTP) using internet transfer control in my application. I'm establishing (and disconnecting) the dialup connection separately(outside my application) . What should I do to do it within my application? If I set the Internet Explorer settings as 'Dial whenever a network connection is not present' or 'Always dial my default connection', then I'm able to connect the dialup within the application. How can I change the settings of the Internet Explorer programmatically? What should I do to disconnect the connection during runtime? ( I tried the method 'Inet1.execute , "Quit" ' .But it doesnt close the connection.) Is there any way to create a new dialup connection using VB code?
0
vkani
Asked:
vkani
  • 3
  • 2
1 Solution
 
edwardiiiCommented:
Hi, vkani.

Regarding initiating a dial-up connection from within VB code, please see the accepted answer here:
http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/VB_Controls/Q_21206662.html?query=disconnect+dial+up&topics=94

All you have to do is replace "NameOfConnection" with the dial-up connection you want to dial.  That will present you with the Dial-up Connection pop-up as it dials the number you've set the connection up with.

To disconnect, I believe you can use the InternetHangUp API:

Private Declare Function InternetHangUp Lib "wininet.dll" _
    (ByVal dwConnection As Long, ByVal dwReserved As Long) As Long

I can't test this because I don't have any dial-up connections anymore, but possibly you can use the same "HandleConnection" value that the link above mentions:

     InternetHangUp Me.hWnd, HandleConnection

Once you've got a connection to the 'Net established, you can process INET commands.  INET's Quit command terminates the INET session, but not the overall connection to the 'Net.

There are also various solutions at this EE post:
http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/VB_Controls/Q_20368757.html?query=InternetDial+Me.hWnd&topics=94
0
 
edwardiiiCommented:
Regarding your question about changing the IE settings programmatically, I'm not finding that code on the 'Net.  But, if you use the method above, you'll connect no matter what someone's IE settings are.  A link with several methods to determine if you are connected via a dial-up connection is here:

http://www.vbcity.com/forums/faq.asp?fid=10&cat=Networking#TID15802
0
 
vkaniAuthor Commented:
Hi Edwardii,
Thanks for your answer.Your code for disconnection works with a slight change:


instead of


You've not answered the last line of my question.(Creating a new dialup connection without using the 'network connections' wizard)

I'll accept your answer irrespective of your response for this, as you've already relieved me of the major problems! Thanks a lot!
0
 
vkaniAuthor Commented:
The correction in your code for disconnection goes like this:
         InternetHangUp HandleConnection,0&
instead of
        InternetHangUp Me.hWnd, HandleConnection.
0
 
edwardiiiCommented:
I'm glad to have helped, vkani.  Thank you very much for sharing the working code to disconnect a dial-up connection:)  It appears that creating a new dial up connection on the fly is more involved than running a line or two of code.  It deals with RAS, which I've not worked with.  You may find what you need by searching this forum for "New dial-up connection"; this link also looks promising:

     http://www.freevbcode.com/ShowCode.asp?ID=1674
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now