Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > General > How to check if internet explorer is work offline?


Reply
 
Thread Tools Display Modes
  #1  
Old 02-24-2009, 01:10 AM
geo1st487's Avatar
geo1st487 geo1st487 is offline
Junior Contributor
 
Join Date: Oct 2002
Posts: 328
Default How to check if internet explorer is work offline?


How to check if internet explorer is work offline?
I want to check if internet explorer work offline is checked and if is true then uncheck work offline (return to online mode).
Thanks

Last edited by geo1st487; 02-24-2009 at 01:26 AM.
Reply With Quote
  #2  
Old 02-24-2009, 05:42 AM
Jonny's Avatar
Jonny Jonny is offline
Senior Contributor
 
Join Date: Jun 2003
Location: Birmingham, England, UK
Posts: 821
Default

You must check the registry key....

"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Inter net Settings\GlobalUserOffline"
Dunno why there's a space in "Internet" but remove it
it will be 1 if Work Offline is ticked
__________________
Regards
John, jlsd.co.uk
Reply With Quote
  #3  
Old 02-24-2009, 09:39 AM
geo1st487's Avatar
geo1st487 geo1st487 is offline
Junior Contributor
 
Join Date: Oct 2002
Posts: 328
Default

Thanks Jonny! I have find API code which check if internet explorer is work offline. I want find code without use registry to enable or disable the work offline.
Reply With Quote
  #4  
Old 02-24-2009, 09:47 AM
webbone's Avatar
webbone webbone is offline
Hydrogen Powered

Administrator
* Expert *
 
Join Date: Jul 2003
Location: Sacramento, CA
Posts: 6,090
Default

geo1st487 - why don't you wish to use any API function calls to achieve your goals? Frequently that is the most straightforward (and fastest) method to do so...
__________________
"With the appearance of the AddressOf operator, an entire industry has developed among authors illustrating how to do previously impossible tasks using Visual Basic. Another industry is rapidly developing among consultants helping users who have gotten into trouble attempting these tasks." -Dan Appleman
Reply With Quote
  #5  
Old 02-24-2009, 09:49 AM
Jonny's Avatar
Jonny Jonny is offline
Senior Contributor
 
Join Date: Jun 2003
Location: Birmingham, England, UK
Posts: 821
Default

There is no API call, you must read/write the registry key.
__________________
Regards
John, jlsd.co.uk
Reply With Quote
  #6  
Old 02-24-2009, 11:15 AM
geo1st487's Avatar
geo1st487 geo1st487 is offline
Junior Contributor
 
Join Date: Oct 2002
Posts: 328
Default

Quote:
Originally Posted by webbone View Post
geo1st487 - why don't you wish to use any API function calls to achieve your goals? Frequently that is the most straightforward (and fastest) method to do so...
Exactly, i want use API function to enable or disable the work offline.
Reply With Quote
  #7  
Old 02-26-2009, 03:01 AM
Jonny's Avatar
Jonny Jonny is offline
Senior Contributor
 
Join Date: Jun 2003
Location: Birmingham, England, UK
Posts: 821
Default

Attached is the module I use for accessing the registry... it's as simple as this to find the work offline value...
Code:
lWorkOffline = GetSettingLong(HKEY_CURRENT_USER, "Software\Microsoft\CurrentVersion\Internet Settings", "GlobalUserOffline", 0)
Attached Files
File Type: bas mRegistry.bas (9.8 KB, 1 views)
__________________
Regards
John, jlsd.co.uk
Reply With Quote
  #8  
Old 02-26-2009, 12:55 PM
geo1st487's Avatar
geo1st487 geo1st487 is offline
Junior Contributor
 
Join Date: Oct 2002
Posts: 328
Default

With changing registry don't uncheck the work offline directly. The best way is the below API code

Code:
Option Explicit

Private Declare Function _
InternetSetOption Lib "Wininet.dll" Alias "InternetSetOptionA" _
(ByVal hInternet As Long, _
ByVal dwOption As Long, _
ByRef lpBuffer As Any, ByVal dwBufferLength As Long) As Long

Private Type INTERNET_CONNECTED_INFO
  dwConnectedState As Long
  dwFlags As Long
End Type

Const INTERNET_STATE_CONNECTED = &H1
Const INTERNET_STATE_DISCONNECTED_BY_USER = &H10
Const ISO_FORCE_DISCONNECTED = &H1
Const INTERNET_OPTION_CONNECTED_STATE = 50


Public Sub GoOffline(mOffline As Boolean)
  Dim mInt As Long
  Dim iso As INTERNET_CONNECTED_INFO

  If mOffline = True Then
      iso.dwConnectedState = INTERNET_STATE_DISCONNECTED_BY_USER
      iso.dwFlags = ISO_FORCE_DISCONNECTED
  Else
      iso.dwConnectedState = INTERNET_STATE_CONNECTED
  End If

  mInt = InternetSetOption(0&, INTERNET_OPTION_CONNECTED_STATE, iso, Len(iso))
End Sub


Sub main()
  GoOffline False
End Sub
Reply With Quote
  #9  
Old 02-26-2009, 05:18 PM
Jonny's Avatar
Jonny Jonny is offline
Senior Contributor
 
Join Date: Jun 2003
Location: Birmingham, England, UK
Posts: 821
Default

Or use that lol :d use registry to read key value still maybe
__________________
Regards
John, jlsd.co.uk
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->