473,385 Members | 1,944 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,385 software developers and data experts.

Figure internet connectivity or webpage accessibility

when i want to know internet connection i use below code ..

WebRequest Request = WebRequest.Create(new Uri( HOME ));

if (Request.GetResponse().ToString().Length > 0)
{
result = true;
}

but this code is so delay..

are there the other method to solve this problem..?
Nov 16 '05 #1
2 1681
DotNetMania,

You can call the InternetGetConnectedStateEx function in the WinInet
library through the P/Invoke layer to do this. You can use this code:

[DllImport("WinInet.dll", CharSet=CharSet.Auto)]
public static extern bool InternetGetConnectedStateEx(
[MarshalAs(UnmanagedType.U4)] int lpdwFlags,
StringBuilder lpszConnectionName,

[MarshalAs(UnmanagedType.U4)] int dwNameLen,
[MarshalAs(UnmanagedType.U4)] int dwReserved);

You can get the values to pass in from the documentation for this
function.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"DotNetMania" <km*****@msn.com> wrote in message
news:eu**************@tk2msftngp13.phx.gbl...
when i want to know internet connection i use below code ..

WebRequest Request = WebRequest.Create(new Uri( HOME ));

if (Request.GetResponse().ToString().Length > 0)
{
result = true;
}

but this code is so delay..

are there the other method to solve this problem..?

Nov 16 '05 #2
hi
this is a good atrtical on how to use the C# ping
http://www.csharphelp.com/archives/archive6.html
Mohamed Mahfouz
MEA Developer Support Center
ITworx on behalf of Microsoft EMEA GTSC

Nov 16 '05 #3

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

Similar topics

4
by: John Riddle | last post by:
Hello, I have an application that runs continously gives an error and stops working if the internet goes down (which happens for about 5-10 minutes several times a day. Can anybody tell me how...
4
by: perspolis | last post by:
Hi all How can I find that user is connected to internet or not? thanks in advance
0
by: Pheasant Plucker® | last post by:
Hi there, Not sure if this is the correct ng and I am not a programmer so excuse me but here goes...:-) We have a custom application that has a hook or calls either the Outlook calendar or...
6
by: =?Utf-8?B?QnNtZW5nZW4=?= | last post by:
I am trying to make sure that the local connection is up. I have presently been using the NetworkChange.NetworkAvailabilityChanged Event for this. Is there a better way to do this? Also, I...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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.