473,387 Members | 3,750 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Dial Up NetWorking (DUN) in VB.Net

Hi,

Sorry, I have to put same message more than three to four times , as I can't
receive a responce.

I want to connect my internet connection through my VB.Net Code.
Is there any sample code, or hints.

Thanks in advance.

Hardik Shah.


Nov 21 '05 #1
2 6062
"Hardik Shah" <ha********@hotmail.com> schrieb:
I want to connect my internet connection through my VB.Net Code.
Is there any sample code, or hints.


\\\

' 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
///

Usage:

\\\
InternetDialer.Dialup(InternetDialer.AutoDialOptio ns.ForceOnline)
..
..
..
InternetDialer.Hangup()
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #2
Herfried,

Regarding the code you posted, I have two questions:

1. This code seems to open/close an existing Dial-up connection that is
already set up on the computer. Do you know of a sample code where you can
supply the Dialup Function with the DialUp parameters (such as phone number,
user name, password, etc.)?

2. In the Sub Dialup, I received this error "Type 'Control' is not defined.
Do I need to import something in this class?

"Herfried K. Wagner [MVP]" wrote:
"Hardik Shah" <ha********@hotmail.com> schrieb:
I want to connect my internet connection through my VB.Net Code.
Is there any sample code, or hints.


\\\

' 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
///

Usage:

\\\
InternetDialer.Dialup(InternetDialer.AutoDialOptio ns.ForceOnline)
..
..
..
InternetDialer.Hangup()
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Dec 8 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: ch | last post by:
Hi, I am trying to write a VB program to detect the Dial Up Networking window in WinXP. For instance, everytime when i launch my Internet Explorer, the default MS windows Dial Up Networking will...
0
by: BrendonJ | last post by:
Hi. Could some one please point me in the right direction about vb.net support for Dial-up connectors? I could not find any documentation. Using VB.NET I would like to search the computer for...
0
by: BrendonJ | last post by:
Hi. Could some one please point me in the right direction about vb.net support for Dial-up connectors? I could not find any documentation. Using VB.NET I would like to search the computer for...
1
by: Hugh McLaughlin | last post by:
Hello Everyone and thanks for your help in advance. I am writing an application in Vb.Net that queries a SQL Server database and then builds a text file for submission to a vendor. However, the...
0
by: Davide Bedin | last post by:
Our .net application needs to open a dial up network connection to reach the internet and send and receive emails (we use a third party component for the email). Using wininet.ddl and...
0
by: sleepyant | last post by:
Hi, how can I check the internet connection and pop-up a Dial-Up Networking dialog when there isn't any? I've tried the following: Dim myReq As HttpWebRequest Try myReq =...
9
by: sleepyant | last post by:
Hi, I've posted this question on several forum but have no response. So I hope anyone who have any idea what I'm talking about please give your solution or advice. My problem is I need to check...
2
by: Tibby | last post by:
I have probably asked this before, but can't find it. Does anyone know of a way that I can make a Dialup Networking Controller? I need to make a program such as NetZero's Dialer, and I know that...
0
by: Axel | last post by:
Hello all, i've a problem with connection to a VPN Network through WinInet API. Scenario: 1 got 2 RAS-connections on my System: one for dialing into the internet via modem and the second for...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.