Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Using MS Comm Control

Posted on 1998-11-15
5
Medium Priority
?
165 Views
Last Modified: 2010-04-30
Can anyone tell me or give me the code to add to a program that will allow the program to use the Dial-up settings in the Internet Properties of windows 95 so that the program will dial the users ISP and sign on with their login and password?
0
Comment
Question by:timothy1
  • 3
  • 2
5 Comments
 

Accepted Solution

by:
MrOBrian earned 200 total points
ID: 1444966
Here's some useful code that you can use to dial the default ISP, check the connection state, and hangup...

Declare Function InternetAutodial Lib "wininet" (ByVal dwFlags As Long, ByVal dwReserved As Long) As Boolean
Declare Function InternetAutodialHangup Lib "wininet" (ByVal dwReserved As Long) As Boolean
Declare Function InternetGetConnectedState Lib "wininet" (dwFlags As Long, dwReserved As Long) As Long
Global Const INTERNET_AUTODIAL_FORCE_ONLINE = 1
Global Const INTERNET_AUTODIAL_FORCE_UNATTENDED = 2
Global Const INTERNET_AUTODIAL_FAILIFSECURITYCHECK = 4
Global Const INTERNET_CONNECTION_MODEM = 1
Global Const INTERNET_CONNECTION_LAN = 2
Global Const INTERNET_CONNECTION_PROXY = 4
Global Const INTERNET_CONNECTION_MODEM_BUSY = 8

Dim dwFlag As Long
dwFlag = INTERNET_CONNECTION_MODEM Or INTERNET_CONNECTION_LAN Or INTERNET_CONNECTION_PROXY
If InternetGetConnectedState(dwFlag, 0) Then
 Select Case dwFlag
 Case INTERNET_CONNECTION_MODEM
  'Connected via Modem
 Case INTERNET_CONNECTION_LAN
  'Connected via LAN
 Case INTERNET_CONNECTION_PROXY
  'Connected via Proxy
 End Select
Else
 InternetAutodial INTERNET_AUTODIAL_FORCE_UNATTENDED, 0
End If

InternetAutodialHangup 0

0
 

Author Comment

by:timothy1
ID: 1444967
Any hints on how to implement said code?
0
 

Expert Comment

by:MrOBrian
ID: 1444968
Well, what I did was put all the Declare and Global lines in a Module.  The in the form.load event of my project I put all the stuff from Dim to End If, which checks the current connection state and attempts to connect if not connected.  The InternetAutoDialHangup I put in my FileExit routine just before Ending the program, but it can be put anywhere you want to hang up the connection.  I've tried it with a modem and on a networked computer without a modem, it works great, though I haven't really played with the dwFlag to see if it works, my program just wanted to know if it had any kind of connection.
Also be careful with the above code, I just noticed that some of lines were split in two (at least on my screen...) so you might need to do some reconstruction if you cut-and-paste.
0
 

Author Comment

by:timothy1
ID: 1444969
Okay it worked, but I noticed that when I stepped through the program and it got to the:

If InternetGetConnectedState(dwFlag, 0) Then
 Select Case dwFlag
 Case INTERNET_CONNECTION_MODEM
  'Connected via Modem
 Case INTERNET_CONNECTION_LAN
  'Connected via LAN
 Case INTERNET_CONNECTION_PROXY
  'Connected via Proxy
 End Select
Else
 InternetAutodial INTERNET_AUTODIAL_FORCE_UNATTENDED, 0
End If

It always jumped to the Else statement. Am I supposed to replace the 'Connected via modem,lan or proxy with something like:

InternetAutodial INTERNET_CONNECTION_MODEM, 0

or whatever the case maybe?
0
 

Expert Comment

by:MrOBrian
ID: 1444970
No, you should leave it as INTERNET_AUTODIAL_FORCE_UNATTENDED for the InternetAutodial...  I am really not sure about the InternetGetConnectedState, I think it is supposed to return a true/false value, but it is possible that it returns a long, which might evaluate to one of the INTERNET_CONNECTION_* things...  I haven't used it enough to figure out what all it does.
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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

971 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