当我的电脑连接了局域网,但是整个局域网没有连接因特网,此函数返回TRUE吗?
也就是说IsNetworkAlive判断的是连接局域网还是因特网啊?

解决方案 »

  1.   

    应该是局域网. 英特网需要你自己去进行http连接来判断
      

  2.   

    MSDN:
    IsNetworkAlive FunctionThe IsNetworkAlive function determines whether or not a local system is connected to a network, and identifies the type of network connection, for example, a LAN, WAN, or both.
    Syntax
    Bool IsNetworkAlive(
      __out  LPDWORD lpdwFlags
    );Parameters
    lpdwFlags 
    The type of network connection that is available. This parameter can be one of the following values: 
    NETWORK_ALIVE_LAN 
    The computer has one or more LAN cards that are active.NETWORK_ALIVE_WAN 
    The computer has one or more active RAS connections.NETWORK_ALIVE_AOL 
    This flag is not valid. Return Value
    This function returns one of the following values:Return code Description 
    TRUE
     A local system is connected to a network. For information about the type of connection, see the lpdwFlags parameter.
     
    FALSE
     There is no connection. For extended error information, call GetLastError.
     Res
    This function can be used by an application to determine whether or not there is network connectivity before proceeding with network operations. A directory service type of application, e-mail client, or Internet browser can adapt to various types of network connectivity. For example, a printing operation can be deferred until a network connection is available.It may not always be practical for an application to call IsNetworkAlive to determine whether or not a local system is disconnected from a LAN, because IsNetworkAlive can be slow, and it may take too much time for the function to detect that a local system is disconnected. However, IsNetworkAlive can always identify a WAN connectivity at the moment.Note  This function is only available for TCP/IP connections.如果返回值里有NETWORK_ALIVE_WAN,则说明检测到互联网连接了。
    窃以为是通过连接固定的微软的某个服务器进行判断的。