注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

gmd20的个人空间

// 编程和生活

 
 
 

日志

 
 

网络有关的几个api(msdn资料)  

2008-10-18 10:50:37|  分类: 程序设计 |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |

windows本身提供了很多网络相关的接口的

MSDN->MSDN Library->Win32 and COM Development->Networking

http://msdn.microsoft.com/en-us/library/bb960840.aspx

如snmp dhcp rpc upnp Network Monitor ,httpsever , winhttp ,QOS等等.

获取网络连接类型是“本地连接”还是“拨号上网 ”或者“网络已经断开”的api

InternetGetConnectedState Function

Retrieves the connected state of the local system.

Syntax

BOOL InternetGetConnectedState(  __out  LPDWORD lpdwFlags,  __in   DWORD dwReserved);

Parameters

lpdwFlags [out]

Pointer to a variable that receives the connection description. This parameter may return a valid flag even when the function returns FALSE. This parameter can be one or more of the following values.

Value Meaning

INTERNET_CONNECTION_CONFIGURED
0x40

Local system has a valid connection to the Internet, but it might or might not be currently connected.

INTERNET_CONNECTION_LAN
0x02

Local system uses a local area network to connect to the Internet.

INTERNET_CONNECTION_MODEM
0x01

Local system uses a modem to connect to the Internet.

INTERNET_CONNECTION_MODEM_BUSY
0x08

No longer used.

INTERNET_CONNECTION_OFFLINE
0x20

Local system is in offline mode.

INTERNET_CONNECTION_PROXY
0x04

Local system uses a proxy server to connect to the Internet.

dwReserved [in]

This parameter is reserved and must be 0.

Return Value

Returns TRUE if there is an active modem or a LAN Internet connection, or FALSE if there is no Internet connection, or if all possible Internet connections are not currently active. For more information, see the Remarks section.

When InternetGetConnectedState returns FALSE, the application can call GetLastError to retrieve the error code.

Remarks

A return value of TRUE from InternetGetConnectedState indicates that at least one connection to the Internet is available. It does not guarantee that a connection to a specific host can be established. Applications should always check for errors returned from API calls that connect to a server. InternetCheckConnection can be called to determine if a connection to a specific destination can be established.

A return value of TRUE indicates that either the modem connection is active, or a LAN connection is active and a proxy is properly configured for the LAN. A return value of FALSE indicates that neither the modem nor the LAN is connected. If FALSE is returned, the INTERNET_CONNECTION_CONFIGURED flag may be set to indicate that autodial is configured to "always dial" but is not currently active. If autodial is not configured, the function returns FALSE.

Requirements

Client Requires Windows Vista, Windows XP, Windows 2000 Professional, Windows NT Workstation 4.0, Windows Me, Windows 98, or Windows 95.
Server Requires Windows Server 2008, Windows Server 2003, Windows 2000 Server, or Windows NT Server 4.0.
Version Requires Internet Explorer 4.0 or later.
Header Declared in Wininet.h.
Library Use Wininet.lib.
DLL Requires Wininet.dll.

用于拨号 的函数

Establishing a Dial-Up Connection to the Internet

The following functions are used to handle modem connections.

Note   WinINet dial-up functions do not support double-dial connections, SmartCard authentication, or connections that require registry-based certification.

Note   Starting on Windows Vista and Windows Server 2008, the WinINet dial-up functions use the RAS functions to establish a dial-up connection. WinINet supports the functionality documented in the RasDialDlg function.

监控网络连接状态的接口/系统通知消息回调:

ISensNetwork http://msdn.microsoft.com/en-us/library/aa377384(VS.85).aspx

ConnectionLost Method of the ISensNetwork Interface

The ConnectionLost method notifies your application that the specified connection has been dropped.

Note   This method is only available for TCP/IP connections.

Syntax

HRESULT ConnectionLost(  [in]  BSTR bstrConnection,  [in]  ULONG ulType);

Parameters

bstrConnection

For WAN connections, the information passed is the connection name. For WAN connections, the connection name is the name of the phone book entry. For LAN connections, the information passed is "LAN connection".

ulType

Connection type. This value can be one of the following values.

Value Meaning

CONNECTION_LAN
0

The connection is to a Local Area Network (LAN).

CONNECTION_WAN
1

The connection is to a Wide Area Network (WAN).

Return Value

Return code Description

S_OK

Method returned successfully.

Remarks

SENS calls this method to notify your application that the specified connection has been dropped.

Filtering can be performed on the publisher property ulConnectionLostType by setting it to either CONNECTION_LAN or CONNECTION_WAN or both. Use IEventSubscription::PutPublisherProperty to set the publisher property.

Requirements

Client Requires Windows Vista, Windows XP, or Windows 2000 Professional.
Server Requires Windows Server 2008, Windows Server 2003, or Windows 2000 Server.
Header

Declared in Sensevts.h; include Sensevts.h and Sens.h.

Type Library

Use Sensevts.tlb.

DLL

Requires Sens.dll.

IID

IID_ISensNetwork is defined as d597bab1-5b9f-11d1-8dd2-00aa004abd5e

ISensOnNow 监控电池使用回调接口http://msdn.microsoft.com/en-us/library/aa377495(VS.85).aspx

电池电量低消息监控

BatteryLow Method of the ISensOnNow Interface

The BatteryLow method notifies an application that battery power is low. SENS calls the BatteryLow method to notify an application that a computer is using battery power.

Low battery power is signaled when a system is on battery power and the battery is low according to the same logic used by the Advanced Power Management (APM) event PBT_APMBATTERYLOW. This event is broadcast when a system APM BIOS sends an APM battery low notification.

Some APM BIOS implementations do not provide notifications when batteries are low, which means that this event may never be broadcast on some computers.

Syntax

HRESULT BatteryLow(  [in]  DWORD dwBatteryLifePercent);

Parameters

dwBatteryLifePercent

The percent of battery power that remains.

Return Value

Return code Description

S_OK

The method returns successfully.

Remarks

SENS calls this method to notify an application that a computer is using battery power. The remaining percentage of battery power is specified.

Requirements

Client Requires Windows Vista, Windows XP, or Windows 2000 Professional.
Server Requires Windows Server 2008, Windows Server 2003, or Windows 2000 Server.
Header

Declared in Sensevts.h.

Type Library

Use Sensevts.tlb.

DLL

Requires Sens.dll.

IID

IID_ISensOnNow is defined as d597bab2-5b9f-11d1-8dd2-00aa004abd5e

  评论这张
 
阅读(713)| 评论(0)
推荐 转载

历史上的今天

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2017