Home All Groups Group Topic Archive Search About

Auto-stop DUN via VB.Net?

Author
28 Mar 2006 8:28 PM
TofuTheGreat@gmail.com
Here's a good one for the gurus out there.

I'm building a custom application that will query a web-service to get
data.  The users are broken into two groups.  Group 1 is the in-office
staff that are connected to the network.  Group 2 is the remote staff
that must connect via dial-up connection to the Internet to use the
web-service.

The user (a.k.a. boss) would like the application to automatically
close the dial-up connection if there hasn't been any activity for 10
minutes.  Anyone like to share a way to programmatically launch a
dial-up connection and then close it from within my application?  Even
pointing me to KB articles would be good.

Author
28 Mar 2006 9:27 PM
Mythran
<TofuTheGr***@gmail.com> wrote in message
Show quoteHide quote
news:1143577687.861249.316750@g10g2000cwb.googlegroups.com...
> Here's a good one for the gurus out there.
>
> I'm building a custom application that will query a web-service to get
> data.  The users are broken into two groups.  Group 1 is the in-office
> staff that are connected to the network.  Group 2 is the remote staff
> that must connect via dial-up connection to the Internet to use the
> web-service.
>
> The user (a.k.a. boss) would like the application to automatically
> close the dial-up connection if there hasn't been any activity for 10
> minutes.  Anyone like to share a way to programmatically launch a
> dial-up connection and then close it from within my application?  Even
> pointing me to KB articles would be good.
>

Copied from Herfried's post from last year (google is great):

\\\

' Written by Herfried K. Wagner.
Public Class InternetDialer
    Public Declare Function InternetAutodial Lib "wininet.dll" ( _
        ByVal dwFlags As Int32, _
        ByVal hwndParent As IntPtr _
    ) As Boolean

    Private Const INTERNET_AUTODIAL_FORCE_ONLINE As Int32 = &H1
    Private Const INTERNET_AUTODIAL_FORCE_UNATTENDED As Int32 = &H2
    Private Const INTERNET_AUTODIAL_FAILIFSECURITYCHECK As Int32 = &H4
    Private Const INTERNET_AUTODIAL_OVERRIDE_NET_PRESENT As Int32 = &H8

    Private Declare Function InternetAutodialHangup Lib "wininet.dll" ( _
        ByVal dwReserved As Int32 _
    ) As Boolean

    Public Enum AutoDialOptions
        ForceOnline = INTERNET_AUTODIAL_FORCE_ONLINE
        ForceUnattended = INTERNET_AUTODIAL_FORCE_UNATTENDED
        FailIfSecurityCheck = INTERNET_AUTODIAL_FAILIFSECURITYCHECK
        OverrideNetPresent = INTERNET_AUTODIAL_OVERRIDE_NET_PRESENT
    End Enum

    Public Shared Sub Dialup(ByVal Options As AutoDialOptions)
        Dialup(Options, IntPtr.Zero)
    End Sub

    Public Shared Sub Dialup(ByVal Options As AutoDialOptions, ByVal Parent
As Control)
        Dialup(Options, Parent.Handle)
    End Sub

    Public Shared Sub Dialup( _
        ByVal Options As AutoDialOptions, _
        ByVal hwndParent As IntPtr _
    )
        If Not InternetAutodial(Options, hwndParent) Then
            Throw _
                New ApplicationException( _
                    "Error dialling the default internet connection." _
                )
        End If
    End Sub

    Public Shared Sub Hangup()
        If Not InternetAutodialHangup(0) Then
            Throw _
                New ApplicationException( _
                    "Error disconnecting internet connection." _
                )
        End If
    End Sub
End Class
///

HTH,
Mythran
Author
29 Mar 2006 4:03 AM
TofuTheGreat@gmail.com
Thanks Mythran!  For some reason all I could find was for the
MarshallSoft component (which would've been the last resort).  Then
right before reading your post I found
http://www.developerfusion.co.uk/show/1920/1/ so I'm sure one of the
two will work.

Thanks again!