Members

Technology Zones

IBM Learning Center

Articles

Hosted By

MaximumASP

Info

Rated
Read 36,834 times

Contents

Downloads

Related Categories

Controlling Dial Up Networking using the WinInet API - Introduction

Introduction

This article explains the basics of controling your DUN([D]ial [U]p [N]etworking) via the WinInet API Function to see if theres an active connection, dial a connection if there isnt or hangup if there is.If your working on a browser based or something to do with the internet then this article may help you.

I've seen many people using the following to get the status of the internet connection:

Function ActiveConnection() As Boolean
 Dim hKey As Long
 Dim lpSubKey As String
 Dim phkResult As Long
 Dim lpValueName As String
 Dim lpReserved As Long
 Dim lpType As Long
 Dim lpData As Long
 Dim lpcbData As Long
   ActiveConnection = False
   lpSubKey = "System\CurrentControlSet\Services\RemoteAccess"
   ReturnCode = RegOpenKey(HKEY_LOCAL_MACHINE, lpSubKey, phkResult)

   If ReturnCode = ERROR_SUCCESS Then
       hKey = phkResult
       lpValueName = "Remote Connection"
       lpReserved = APINULL
       lpType = APINULL
       lpData = APINULL
       lpcbData = APINULL
       ReturnCode = RegQueryValueEx(hKey, lpValueName, lpReserved, lpType, ByVal lpData, lpcbData)
       lpcbData = Len(lpData)
       ReturnCode = RegQueryValueEx(hKey, lpValueName, lpReserved, lpType, lpData, lpcbData)
                   
       If ReturnCode = ERROR_SUCCESS Then
           If lpData = 0 Then
               ActiveConnection = False
             Else
               ActiveConnection = True
           End If
       End If
                               
       RegCloseKey (hKey)
   End If

End Function

The above code was taken from a project by someone else, and I DON'T TAKE ANY CREDIT FOR IT. The code is alright if you arr prepared to add the API functions for the Windows Registry. But if your like me, I like to do things and keep the code to the minimal. I usually code my functions into a handy DLL (ActiveX DLL-[D]ynamic [L]ink [L]ibrary) which I use it mostly all my projects. Its easier and more efficent in some ways. If you were to add the above code to a DLL then you would add the registry code or add dependencies to one.

Work Work Work
Currently I'm working at Vividas Pty Ltd and studying at Swinburne University. My time on DeveloperFusion is limited due to workloads on both parts, I do however keep a Blog that gets updated fairly regularly with lots of Techno-babble...

I also have a software business called WebSoftware Systems in Australia, the primary product we have at the moment is HotHTML which started life as a simple VB6 based HTML editor and is now a full blown text/web development IDE. I'm currently also working on the v4.0 release in .NET 2.0.

Comments

  • any idea of how to create a shortcut for a dial-up

    Posted by RUK007 on 09 Jul 2005

    Hi guys does anybody in this place have any idea of how to create a shortcut to an existing dial-up connection in VB (or any language)???
    I'm sick of searching this,i'm searching this for around a mo...

  • Posted by novecento on 19 Jun 2004

    [quote][1]Posted by [b]misslav[/b] on 2 Apr 2004 02:33 AM[/1]
    Does someone know how to hide dial-up dialog box?
    [/quote]

    i have teh same issue and can't find a solution. do you found out how to d...

  • WinInet

    Posted by misslav on 02 Apr 2004

    Does someone know how to hide dial-up dialog box?

  • Hide Dial up Dialog box

    Posted by TimTDP on 03 Feb 2004

    How can I prevent the dial up dialog box from being displayed?

  • Posted by Thushan Fernando on 16 Dec 2003

    ummmm i'm confused Farad'n, what exactly do you mean rip from a COM server?