Solved

Using MS Comm Control

Posted on 1998-11-15
5
139 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 50 total points
Comment Utility
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
Comment Utility
Any hints on how to implement said code?
0
 

Expert Comment

by:MrOBrian
Comment Utility
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
Comment Utility
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
Comment Utility
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

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

10 Experts available now in Live!

Get 1:1 Help Now