Using MS Comm Control

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?
timothy1Asked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
MrOBrianConnect With a Mentor Commented:
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
 
timothy1Author Commented:
Any hints on how to implement said code?
0
 
MrOBrianCommented:
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
 
timothy1Author Commented:
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
 
MrOBrianCommented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.