Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Using MS Comm Control

Posted on 1998-11-15
5
Medium Priority
?
162 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
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.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

719 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