Library tutorials & articles
Controlling Dial Up Networking using the WinInet API
- Introduction
- Are we connected?
- Connecting & Disconnecting
Are we connected?
So to solve that problem heres a cleaner clear cut API based function which will get the result done faster and more efficiently without alot of coding. Not only that its compact so you can easily add this to a module or do as I do and make it into a DLL.
Private Declare Function InternetGetConnectedStateEx Lib "wininet.dll"
Alias "InternetGetConnectedStateExA" (lpdwFlags As Long, lpszConnectionName As
Long, dwNameLen As Long, ByVal dwReserved As Long) As Long
Public Function Connected() As Boolean
Dim lNameLen As Long
Dim lRetVal As Long
Dim lConnectionFlags As Long
Dim LPTR As
Long
Dim lNameLenPtr As Long
Dim sConnectionName As String
sConnectionName = Space$(256)
lNameLen = 256
LPTR = StrPtr(sConnectionName)
lNameLenPtr = VarPtr(lNameLen)
lRetVal = InternetGetConnectedStateEx(lConnectionFlags, ByVal LPTR,
ByVal lNameLen, 0&)
Connected = (lRetVal <> 0)
End Function
The function will use the InternetGetConnectedState function in the wininet DLL file to see if your are connected to the internet. It will return TRUE if it is or FALSE if it isnt.
Related articles
Related discussion
-
VB6 Runtime error 381 subsript out of range Error
by Uncle (2 replies)
-
passing and reading parameters from using Shell
by jigartoliya (0 replies)
-
Convert C++ code to VB6
by mawcot (4 replies)
-
listbox scrollbar
by Dennijr (10 replies)
-
Can you describe Above simple VB6 code?
by pramodmca09 (0 replies)
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...
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 month without any success..
if you guys have any idea just let me know..i'm so greatful for that..
Thushan i hope you'll have some solution on this matter as you seems like pretty concern on this subject..
thank you...!
Does someone know how to hide dial-up dialog box?
i have teh same issue and can't find a solution. do you found out how to do it?
cheers
daniel
Does someone know how to hide dial-up dialog box?
ummmm i'm confused Farad'n, what exactly do you mean rip from a COM server?
Just have to check the auto dial on the dun windows and that will be it. of coarse you loose a securyty level by bi-passing the user name and password but if the dun windows would not be showed that securety level would be bi-pass any way... i believe the user is aloud to be aware that the modem is or could be dialing long distance.. so the only use for the disaperance of the dun window would be for develorer witch have bad intention and usualy those dont know how to programe well and dont know how to work api well. i think they should do like all beguiner and get ripp'of by getting ocx and activex control and get the under running code that come's whit it (since those that make activex only mmake a nice pakage of api fonction that look that do only one thing but does alote of other that run in back coding)
any way have fun making your little rip
farad'n
okay well heres a quicky....
Option Explicit
Private Declare Function InternetAutodial Lib "wininet.dll" (ByVal dwFlags As Long, ByVal hwndParent As Long) As Long
Private Const INTERNETAUTODIALFORCEONLINE = 1&
Private Const INTERNETAUTODIALFORCEUNATTENDED = 2&
Private Const INTERNETAUTODIALFAILIFSECURITYCHECK = 4&
Public Enum AutoDialsFlags
ADFFORCEONLINE = INTERNETAUTODIALFORCEONLINE
ADFFORCEUNATTENDED = INTERNETAUTODIALFORCEUNATTENDED
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 INTERNETAUTODIALFAILIFSECURITYCHECK
lRetValue = InternetAutodial(lFlags, hwndParentWindow)
If lRetValue <> 0 Then Autodial = True Else Autodial = False
ErrHandle:
Exit Function
End Function
call it like this to get AutoDial without just showing the dialog:
Autodial hWnd, ADFFORCEUNATTENDED, True
I had exams last 2 weeks so I'm not really in the mood to write any tutorials yet. Give me some time off and I will(its holidays now - woohoooo!
Hope that helps!
Good Luck!
hey,
thanks. I am working on Part II of this tutorial which will tell you how to do Auto-Dialing and some other cool features and wrap it all in a nice class module.
If you cant wait till then I can send you a partly completed code by email. Its not commented yet though.
The codes look nice. But what if my ISP require password and username for authentication? When i run the codes, my modem doesn't autodial?
This thread is for discussions of Controlling Dial Up Networking using the WinInet API.