Library code snippets

AutoDial with WinInet API

This is an addition to my collection of the Windows Inet DLL functions. Shows how to Auto-Dial without the user having to insert usernames and passwords. All Automated!

Simply insert this into a module:

Option Explicit
Private Declare Function InternetAutodial Lib "wininet.dll" (ByVal dwFlags As Long, ByVal hwndParent As Long) As Long
Private Const INTERNET_AUTODIAL_FORCE_ONLINE = 1&
Private Const INTERNET_AUTODIAL_FORCE_UNATTENDED = 2&
Private Const INTERNET_AUTODIAL_FAILIFSECURITYCHECK = 4&
Public Enum AutoDialsFlags
   ADF_FORCE_ONLINE = INTERNET_AUTODIAL_FORCE_ONLINE
   ADF_FORCE_UNATTENDED = INTERNET_AUTODIAL_FORCE_UNATTENDED
End Enum

Public Function Autodial(hwndParentWindow As Long, lOption As AutoDialsFlags, Optional bFailIfSecurityCheck As Boolean = True) As Boolean
Dim lFlags As Long, lRetValue As Long
On Error GoTo ErrHandle
   If bFailIfSecurityCheck Then lFlags = lOption Or INTERNET_AUTODIAL_FAILIFSECURITYCHECK
   lRetValue = InternetAutodial(lFlags, hwndParentWindow)
   If lRetValue <> 0 Then Autodial = True Else Autodial = False
ErrHandle:
   Exit Function
End Function


then call the function to autodial like this:

Autodial hWnd, ADF_FORCE_UNATTENDED, True


This would be a godsend to those writing download managers etc!

Comments

  1. 12 Jul 2003 at 10:48

    maybe theres something declared in there already called AutoDialsFlags... check in your code.


    apologies for hte delay in getting back to you... i dont check what feedback i have on my sbumissions that regularly..

  2. 20 May 2003 at 03:53

    Usually the ambigous name detected means that you already have a variable declared that way.

  3. 16 Apr 2003 at 11:20

    Hi,
    I've tried this code, and it gives me an error "ambiguous name  detected"
    on the "Public Enum AutoDialsFlags"


    Nou I can't figure this out.


    pls help


    using vb6 win98

  4. 01 Jan 1999 at 00:00

    This thread is for discussions of AutoDial with WinInet API.

Leave a comment

Sign in or Join us (it's free).

Thushan Fernando Currently I'm working at Hammond Street Developments Pty Ltd. My time on DeveloperFusion is limited due to workloads, I do however keep a Blog that gets updated fairly regularly with lots of Techno...

Related discussion

Related podcasts

  • Christian Beauclair

    14 mai 2008 (�mission #0074) ::.Christian Beauclair: Stratégies de migration VB6 vers .NET Nous discutons avec Christian Beauclair des stratégies de migration VB6 vers .NET. Entre autres, nous discutons comment utiliser le "VB 6 Code Advisor" et le "Interop Forms Toolkit" pour ajouter la puiss...

Want to stay in touch with what's going on? Follow us on twitter!