麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁 > 編程 > .NET > 正文

Check Your Internet Connection With C#

2024-07-21 02:18:27
字體:
供稿:網(wǎng)友
check your internet connection with c#
by simohamed attahri

用c#檢測你的網(wǎng)絡(luò)連接



how to check if your computer is connected to the internet with c#. it's much more easier that other tutorials i've seen in other sites. in deed, we're going to use a simple api function internetgetconnectedstate, to return a boolean variable.

怎么用c#來檢測你的計(jì)算機(jī)是否連接到互聯(lián)網(wǎng)呢?這可能是我見過最簡單的教程了。其實(shí)我們就是使用一個(gè)簡單的internetgetconnectedstate api函數(shù),結(jié)果是返回一個(gè)boolean類型的變量。

this function takes two arguments :

這個(gè)函數(shù)有兩個(gè)參數(shù):

the first one is an integer used with out keyword, that means that after calling the function, the variable will contain an interger that describes the connection state ( use of a modem, use of a proxy, offline mode...). note that you must refer to www.msdn.com for more information about that.
the second one is a reserved variable that must be set to 0.

第一個(gè)是帶有out關(guān)鍵字的整型數(shù),也就是說在調(diào)用函數(shù)后,變量應(yīng)該包含一個(gè)描述連接狀態(tài)(使用調(diào)制解調(diào)器、使用代理、離線模式)的整型數(shù)。你可以到www.msdn.com獲取更多相關(guān)信息。

第二個(gè)參數(shù)設(shè)置為零的保留變量。

in this tutorial, we'll create a class with a static function that returns true if connected and false if not, using our api function in private state.

在這篇教程中,我們建立一個(gè)有著靜態(tài)函數(shù)的類,在私有域使用api函數(shù)。如果連通則返回true否則返回false。

check this out :

using system ;
using system.runtime ;
using system.runtime.interopservices ;

public class internetcs
{

//creating the extern function...
[dllimport("wininet.dll")]
private extern static bool internetgetconnectedstate( int out description, int reservedvalue ) ;

//creating a function that uses the api function...
public static bool isconnectedtointernet( )
{

int desc ;
return internetgetconnectedstate( out desc, 0 ) ;

}

}

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 久久99国产精品久久99 | 一区在线视频 | 成人福利在线免费观看 | 91av日韩| 国产亚洲精品久久久久5区 男人天堂免费 | 久久2019中文字幕 | 欧美一级做性受免费大片免费 | 日韩在线播放第一页 | 久久人人爽人人爽人人片av高清 | 欧美伦理一区二区 | 欧美精品一区二区三区在线播放 | 一级电影在线观看 | 国产69精品久久久久久久久久 | 羞羞视频2023 | 亚洲视频观看 | 天天色综合2 | 男女羞羞视频在线免费观看 | 国产亚洲精品视频中文字幕 | 久草在线高清视频 | 男人午夜小视频 | 日本a级一区 | 欧洲精品久久久 | 成人男男视频拍拍拍在线观看 | 国产伦精品一区二区三区 | 午夜精品在线视频 | 国产福利视频在线观看 | 亚州综合 | 性高潮一级片 | 九九视频精品在线 | 国产精品久久久久久久久久久久午夜 | 意大利av在线| 欧美成人理论片乱 | 黄色av网站在线观看 | 国产免费专区 | 看片一区二区三区 | 久久免费看毛片 | 久久久久亚洲视频 | 免费的性生活视频 | 日日操夜| 欧美在线观看视频网站 | 日本不卡一区二区在线观看 |