Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  HOME    TRACKER    Visual Basic

How To Determine If Internet Connection Is Active

Hi, I would like to make a program that shuts down the computer when a download or all downloads are complete. I can think of only one way to let the program determine if there are any active downloads, which is to see if the internet connection is active (i.e. significant volume of data is being sent across the connection) or not.

Any idea how to do that (maybe get the total number of packets sent), or is there a better way to determine if there are active downloads in progress?


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Terminating Active Internet Connection - Internet Transfer Control
Just wondering if anyone can tell me how to terminate a connection that has been made with the Internet Transfer Control in VB5.

I have tried the CANCEL method but it doesn't seem to do anything.

An Example Scenario

Determine Internet Connection
Hello everyone,

I've searched through the archives, but haven't had much luck with finding anything that specifically does what i'm looking for.

Basically i'm looking for a code that will determine whether or not I am connected to the internet or not.

Sounds really simple, but hard to actually make it practical, for a newb at least .

The other things that I have found either show that I do have an internet connection, but then when I disconnect from the internet, it still says i'm connected to the internet (I disconnect from the internet and my LAN). And the other form that I really wanted to use was a ping form. Where I can just ping a site and if I do get feedback then I know i'm connected, but the problem was when I disconnected and then tried it...the program would freeze because it couldn't get a ping.

Any help on this issue would be greatly appreciated.

Best regards,


How Can I Determine The SMTP Server Name From An Internet Connection
I need to be able to determine the SMTP outbound mail server name from an Internet Connection on a standalone PC, or from the SMTP name stored on the client PC.

Anybody help?


Active Internet Connection
I use Dial-up, How do I check to see if my conputer is connected to the internet? -Preferable with a function that returns true or false.

Active Internet Connection
I've been using the below to check for an Internet connection which works fine while I'm online but when I'm offline it also returns True?

Is there another way to check for an active internet connection since this method doesn't work?

VB Code:
Private Declare Function InternetGetConnectedState Lib "wininet.dll" (ByRef lpSFlags As Long, ByVal dwReserved As Long) As Long  Private Sub Command1_Click() If InternetGetConnectedState(0, 0) Then     MsgBox "Online" Else     MsgBox "Offline" End If End Sub

Active Internet Connection
After searching quite a bit about this subject, I finally got an idea. I attached it. Plz let me know what you think.

Check To See If There Is An Active Internet Connection.
How can I check to see if there is an active internet connection. Then if there is do sumthing and if there isn't do sumthing else.

How Can I Detect If There Is An Active Internet Connection?
When I dial modem and have internet connection, I want to know
connection state (Connected or Disconnect).

best regards

Check For An Active Internet Connection
I have had SOOOOOOO much trouble with this. I tried using the API
InternetAutodial(INTERNET_FORCE_ONLINE, 0)
to check, but it worked for a bit and then threw up errors in my face.

Anybody know how to check? I mean, can I query the modem or something like that? Any assistance GREATLY appreciated!

Urgent! How Can I Detect An Active Internet Connection In WinNT 4.0?
Urgent! How can I detect an active internet connection in WinNT 4.0?

Detect If There Is An Internet Connection Active Before Winsock.Connect [SOLVED]
How can I detect if there is an internet connection before connecting with Winsock to send an email?

The first time the app tries to connect without an internet connection the winsock_error catches the error, but the second time around (2 minute iterations with a timer) I get an error when winsock tries to connect again, not caught anymore with winsock_error

My connection is DSL (sympatico high speed modem), VB6, W2000


Edit: I tried looking for an answer in other postings but found nothing regarding detecting an internet connection....


Edited by - vbprog1144 on 5/27/2004 12:29:20 AM

How To Determine If The Window Is Active Or Not
Hey, im needing my program to know if the form is the active window, or if it is set in the background.

For the sake of simplicity, lets say i have a timer. The timer should ONLY be enabled when the form form is the active window, and when another window is selected as active, the timer will become disabled.

What API would i use to determine if the window is active or not. Ive ran across an API that causes the window to be active, but i havnt found one yet that will send back some kind of data that will let the application know if its active or not.


Determine Active Printer
Dear All,

How to determine active printer is a dot matrix printer or not? ..


Determine Currently Active COM Components
Hey all,

Does anyone know of any code that will give me a list of all currently active (as in running, instantiated etc) COM components on a system?

--Who Me...
I'm Just

Determine Active Programs
Without using APIs, how can you determine if a program is running and how can you start and stop the program at will from a application?

How To Determine Last Selected Or Active Sheet
I need to create a "navigation" button for a huge workbook with lots of sheets. I have a "control panel" setup to select the different sheets but it gets cumbersome when you have to navigate through mutiple tabs to find the last sheet you were working on. Is there a way to determine what the last sheet selected was and store that in a variable so that I can assign a sub to a "Back" button and be able to navigate directly to there? Also, would you see a need for a "Forward" button as well like on IE?

Determine Which Application Window Is Active
Is there any way i can determine which application window is active? Let's say notepad,IE,etc.
How can i close such application window?

Thanks in advance!

How To Determine What Windows Are Active And Not Minimized
I made a (Windows XP) VB6 'hotkey' app that is open all the time 'listening' for certain Fkeys.
Sometimes, hotkey loses focus (e.g. when the desktop is clicked).
I found that I can regain focus automatically by starting a 1 second timer when WM_NCACTIVATE is detected by my windows messaging hook. At timer expiration, I can set focus for my hotkey app. However, I ONLY want to grab focus if there are no windows currently active on the desktop. Otherwise, I steal focus from an active application window and have to click that window to restore it's focus.

Unfortunately, after almost a week of surfing, I haven't found a way to scan for windows that are actually visibly open on the desktop (if they are active, but minimized to the taskbar, I don't care about them).

I have API code that I use to scan all active windows and get the window name - all I need now is to get some sort of status for each that will differentiate 'Iconized' apps from visible (not minimized).

Do you know API methods that can give me the information to determine this?

Frank Brady

Determine Active Tab - SSTab ** Resolved **
I want to know how I can tell which tab of a SSTab control is active?

Any suggestions?


MDIform To Determine Active MDIChild Forms
Hello all,

I have an MDIform and MDIchild forms.

My question really is how can i determine how many MDIChild forms are active?
I tried using screen.activeform but there's no other option or properties that will lead me to determine how many mdichild forms are open.

can somebody help me.

Thank you

How Can Form2 Determine What Is/was The Active Control On Form1
I recently found out I can use ActiveControl to get the currently focused control on Form1. I am assuming when I load Form2 then there will not be any active controls located on Form1 anymore since Form2 is now the active Form ..... is this correct?

My goal is to have Form2 realize which control was active on Form1 at the time Form2 was loaded. Basically, my Form2 is going to be a keyboard which allows the user to enter data via mouse-clicking on the appropriate buttons. However, when the user clicks on buttons, then I must know what textBox controls located on Form1 should be updated with the entered character data.

Before Form2 would be loaded, the user would click on a certain textBox to add data, then click on a KeyBoard button which will load Form2 (ie: keyboard form). Somehow Form2 has to know what textBox the data is for ......

Maybe the ActiveControl.Form1 logic can be used within Form2 code? If not, then do you have any ideas how to approach this?

PS: Is there a way to pass a parameter into Form2 as part of the loading sequence? This parameter would indicate which control the data is related. Although, this way would only work if Form2 was loaded as vbModal. If the user wanted to keep the Keyboard form open all the time and then use it as needed, then this approach would not work ...... and this is what the user might want to do ... so maybe this idea is not good either..

Any help would be appreciated..

Using API To Determine When A Program Is Trying To Access The Internet
I am in the begining stages of creating a program in VB that will monitor and report on software active on my computer and will allow me the ability to block the software from accessing the internet, something similar to zonealarm. I am not even sure where to begin. There must be an api or hook that will let the program know what and when something is trying to access the network (or internet). It could be similar to the netstat command. I am not to worried about things trying to connect to my computer. I am worried that zonealarm is letting some programs (for whatever reason $$$) access the net and report on my activites.

Any ideas would be greatly appreciated.

Troy Williams B.Eng.

How 2 Disconect Internet Connection Or Lan Connection Using Code
hello firiends

can any body have idea that i want disconnect the lan connection or internet connection after some perticular time assigned to perticular user.

i want todo it with vb code .

can any body guide me.

Thanks in advance for guidence


How To Determine Connection Speed
Is there an API call to determine the connection speed of the network?

I want to know if someone is connection the network on a dial up connection.


Determine Connection Speed
How do you determine what kind of a connection(diaup, DSL, cable, etc) that someone is hooked up to the internet with?

How do you determine what their connection speed is? I know how to do it with a dialup connection but I don't have the slightest clue when it comes to DSL, cable, etc. I've seen programs on vbnet and planetsourcecode that shows everything and much more. Trying to figure out what lines of code are actually performing the work of finding the connection and dictating its speed is the problem.


How Can I Determine Where The Internet Temporary Files Folder Is?

how can I determine where the internet temporary files folder is
on the user's computer using vb?


Determine If ADO Connection Object Exists
I have an application with several windows that open and close connections to two databases. For closing aconnection I use the following code:

If conADO.State = adStateOpen Then
Set conADO = Nothing
End If

However this creates problems if more than one windows are open. I use this code in the Form Unload event of each form. So, if a window closes, the connection closes. The next window that tries to close the connection gives an error.

How could I avoid this situation? Is there a way to check if the connection object exists instead of just been open, as the above code does?

Thanks in advance

Determine Lost Connection On Downloads
I am using WinHTTP.dll to download files. If unplug my connection while program is dowloading it just stops with no error messages. I would like to inform the user of the lost connection. How can i determine when the connection has been lost ?

Determine Network Connection Mb Thoroughput?
Can anybody suggest the best way to determine network connection throughput in Mb?

We sell Internet connection by satellite, but the service supplier degrades the service (Fair Access Policy) if the user downloads over a certain Mb limit in a certain time. This is done without warning and I am looking to write a utility to let the customer know when approaching the limit.

The satellite connection appears like a network connection(physically it is a USB connection and associated driver software)

Any ideas?

How Should I Determine Lost Database Connection
I have vb application which opens jet database as follows

dim dbTime as Database
set rsEx1 as Recordset
Set dbTime = OpenDatabase("Example.mdb")
set rsEx1 = dbTime.OpenRecordset("Table 1", dbOpenSnapshot)

Now I am saving variable dbTime globally and use it for opening recordsets for various times. Everything works fine.

However, when my program reamins idle for 5 mins or so and then I try to open recordset, it gives me following error
"Run Time Error 3112
Records can't be read; no read permission on 'Table 1' "
and then the program crashes.

To me it looks like that I am loosing my database connection when program remains idle.

However, is there any way that before opening recordset from my database varible dbTime, can I check if it is valid database object or closed or something like that so that I can open it again if its closed and save my program from abnormal crashing.

Any help will be greatly appreciated
Thanx a lot

Determine File Size And FTP Connection Speed
How do I determine:

1. the size of a file and store it in a variable?
2. my connection speed to an FTP server through the Inet tool?

Active X Internet App
Just a general question. I made an OCX that I wanna put on a web page. I also made a setup CAB for the OCX. What I wanna know is when I publish the page on the internet-will it automatically download the setup cab for the ocx or will I have to provide a link for that?


How To Determine If The DSNless Connection Is Present And Mapped Drive Is Correct, Etc..
Hi guys.. I'm writing a small to medium size app for a government agency. The problem is that the app's database / access.mdb will be stored on a file server, either NT or Novell. That said, I was going to set up a DSNless file connection string to hit the database via ADO, but I'm afraid the mapped drive will get changed to something else in the future which will mess this up.. Is there a way in code to check to see if a Database resides on the server and what mapped drive the user has to the path of the file server and database? Does that make sense? I hope so..

My thought was to query a table in the database to see if I can get any records.. I was going to stick up a table with say 3 records in it and use it for nothing but checking the connection to the database..

Thanks so much


Internet Explorer Active-X Name
I am trying to load internet explorer on the fly into my application.

how is IE registered?


doesn't work

Name Of Active DUN Connection
My VB application needs to get the name of the Dial Up networking Connection name, if the user is conencted ot the internet. Though I have figured out how to check if user is online, how do i get the conenction name? Can I disconnect it to?


Active Connection
How do i check to see if there is an internet connection active. Is there an activex to do this?? Dont mind if it is code though..

Connection Active
Dear All,

I like to know whether it is possible from vb 6 to know whether the computer is connected to the internet or in other words the dial up connection is active or working

Thanks is advance


Detect Active Connection Name
Is there a way to detect the name of an active inernet (modem)


Best Way To Check For Active Connection
HeY, I made a Winsock Server / Client Program. I need a way to the client to constantly check for an active connection. Would I good lOop work. I toought I would ask for advice before doing anything. Thanks

Detecting Active RAS Connection
I need to write a program that checks to see if RAS
is holding an open connection. In windows 98 this
is in the registry, not so on NT & W2K.

Any advice is greatly appreciated

Network Connection Active
Hi all,
I have a few computers theat are on a network.
I have made a form with command buttons layed out like a floorplan, one for each computer.
When you click on a button it opens up a remote desktop program.

Is there a way for the form to scan the network and change the button color of machines either on or not connected to the network?
If so, could somebody help me with this?

Thanks in advance.

Calling The Active Connection
I am moving from dAO to ADO (in Access, for the moment) and I would like that, once the connection opened (connection to a mdb, let's say) I could call it from anywhere in the application (like using a global variable) in order to avoid "opening" and opening the connection every time.

How this is to be done, please?


Check If RDO Connection Is Still Active
I'm having a problem with VB6 causing a major error and closing up my project when it tries to execute an insert query.

The application is already using RDO and this statement is executed multiple times before the program closes.

Is there a way to check if the connection is still active before I execute this query?

This is the execute statement I'm using:

glblObjConnectionEPC.Execute sSQL

So I need a possible check on the connection before hand.


Keep Database Connection Active
Hi gurus,

I am using Oracle 10g database as back end and VB as front end.
I connect to the database just fine. I press the search button and the result is returned with no problems. If i just go to the toilet for a bit and come back to search again, the search takes sometime, the same time it takes when connecting to the the database.

The connection object is created just when the application starts the ends when the application is ended.
So, when i click on search, it creates a recordset and passes the sql statement to the connection.

How do i keep the connection open (active) for a long time?

Please help.

Checking For Active Network/internet Connections
I am trying to write a program that will detect whether or not my PC is connected to a LAN or connected to another source via Dial-up networking. I've tried using the InternetGetConnectedState function, but it doesn't seem to be working properly. It detects when my PC is connected to the internet via Dial-up Networking or not, but it doesn't properly detect when my LAN connection is lost. Even if I physically disconnect my LAN cable, the program tells my that I have an active connection via my LAN.
Has anyone out there ever experienced this? What can I try to solve the problem?


Jeff Crumb

Get The LocationURL From The Active Internet Explorter Window

My ultimate goal is to get the LocationURL from the active Internet Explorer Window. I have been trying to use "GetObject("","InternetExplorer.Application"), but unfortunately this code will create a new Internet Explorer Window.

I have also consider using DDE, but I don't know enough about DDE to implement it.

Any information that you could provide to help me get the LocationURL from the active internet Explorer Windows would be greatly appreciated. Thanks for your time!



Problems With Connection To Active Directory

When i would connect to active directory with aditional credentials and i would get an object i get an automation error can someone help me:

the script

cn.Provider = "ADsDSOObject"
cn.Properties("User ID") = username
cn.Properties("Password") = myPassw
cn.Properties("Encrypt Password") = True
cn.Properties("Mode") = 3
cn.Open "ADProvider", username, myPassw
Set cm.ActiveConnection = cn

cm.CommandText = "<LDAP://,DC=local>;" & "(&(objectCategory=person)(objectClass=user)(samaccountname=testuser)) ;ADsPath;subtree"
cm.Properties("Page Size") = 1000
Set rs = cm.Execute

With rs
If Not .EOF Then
Set User = GetObject(rs("ADsPath"))
User.SetPassword ("service4")
ChangePassword = True
End If
End With
i get the error on the line with set user = getobject(...........

the reason is that i have no right to do this operation when i make myself domain admin it is no problem

MSSQL Connection Ramains Active!!!
Hi there!

I am having a weird issue with SQL-Server 2000.
I just finishes to write a little administration tool, where one of the
options allow the administrator to create an entire database from a
script. Well, because this database can already exists in MSSQL, I must
drop it before to recreate it.
Take a look what I do:

'Open SQL-Server connection with no database reference
'I must do not pass any database name or else I cannot drop the desired database
'OpenSQLServerLocal is a sub that passes the connection string and where the first parameter is the database name

OpenSQLServerLocal "", "sa", ""

'Open the text file with the script
Open App.Path & "" & "script.txt" For Input As #1

'Drop database and recreate it
Set rsc = Conn.Execute("IF EXISTS (SELECT name FROM master.dbo.sysdatabases WHERE name = N'" & TheDBName & "')DROP DATABASE [" & TheDBName & "]")
Set rsc = Conn.Execute("CREATE DATABASE [" & TheDBName & "] ON (NAME = N'" & TheDBName & "Data', FILENAME = N'" & gpMSSQLPath & TheDBName & "_Data.MDF' , SIZE = 1, FILEGROWTH = 1) LOG ON (NAME = N'" & TheDBName & "Log', FILENAME = N'" & gpMSSQLPath & TheDBName & "_Log.LDF' , SIZE = 1, FILEGROWTH = 10%)")

'Close SQL-Server connection
Set Conn = Nothing

'Open SQL-Server connecting to the created database
OpenSQLServerLocal TheDBName, "sa", ""

'Create database tables from the script text file
Do Until EOF(1)
Line Input #1, StrLineIn
Set rsc = Conn.Execute(StrLineIn)
Close (1)

'Close database
Set Conn = Nothing

Well, no big deal, uh? The problem is that, when I click the button to create the database, everything runs fine.
But, if I click it again, the system hangs for a while, and then returns with an erros saying that
"cannot drop database because it is in use". I think it's very weird once I am droping the connection after recreate
the database and the tables. I tried to use just Conn.Close, to use Set Conn = Nothing and the both. Nothing seems to work...

Any clues?


Error While Setting Active Connection
When setting the active connection of my command object to my connection object I get an error saying

"ADODB.Command (0x800A0E7D)
Requested operation requires an OLE DB Session object, which is not supported by the current provider."

With cmdGetSystemType
Set .ActiveConnection = objConn
.CommandText = "sp_GetSystemType"
.CommandType = adCmdStoredProc
End With

The error is in the second line of the code above

I'm trying to run a stored procedure from SQL Server 2000 in VB 6.0 using a COM object. Any help is appreciated


Copyright 2005-08, All rights reserved