檢查網路是否串連正常

來源:互聯網
上載者:User

標頭檔     WinInet.h    
靜態庫     WinInet.lib    

BOOL   InternetGetConnectedState(  
          OUT   LPDWORD   lpdwFlags,  
          IN     DWORD   dwReserved  
  );  

 

  DWORD   flags;//上網方式  
  BOOL     m_bOnline;//是否線上  
  m_bOnline=InternetGetConnectedState(&flags,0);  
  if(m_bOnline)//線上  
  {  
          switch(&flags)  
          {  

          case   INTERNET_CONNECTION_MODEM   :  
                  AfxMessageBox("線上:撥接");  
                  break;  
          case   INTERNET_CONNECTION_LAN   :  
                  AfxMessageBox("線上:通過區域網路");  
                  break;  
          case   INTERNET_CONNECTION_PROXY   :  
                  AfxMessageBox("線上:代理");  
                  break;  
          }  
          if(&flags==INTERNET_CONNECTION_MODEM_BUSY)  
                  AfxMessageBox("MODEM被其他非INTERNET串連佔用");  
  }  
  else  
              AfxMessageBox("不線上");

 

另外MSDN上有更多的解釋:

Parameters  
   
  lpdwFlags    
  Address   of   an   unsigned   long   integer   variable   where   the   connection   description   should   be   returned.   This   can   be   a   combination   of   the   following   values:    
  INTERNET_CONNECTION_CONFIGURED    
  Local   system   has   a   valid   connection   to   the   Internet,   but   it   may   or   may   not   be   currently   connected.    
  INTERNET_CONNECTION_LAN    
  Local   system   uses   a   local   area   network   to   connect   to   the   Internet.    
  INTERNET_CONNECTION_MODEM    
  Local   system   uses   a   modem   to   connect   to   the   Internet.    
  INTERNET_CONNECTION_MODEM_BUSY    
  No   longer   used.    
  INTERNET_CONNECTION_OFFLINE    
  Local   system   is   in   offline   mode.    
  INTERNET_CONNECTION_PROXY    
  Local   system   uses   a   proxy   server   to   connect   to   the   Internet.    
  INTERNET_RAS_INSTALLED    
  Local   system   has   RAS   installed.    
  dwReserved    
  Reserved.   Must   be   set   to   zero.    
  Return   Value  
   
  Returns   TRUE   if   there   is   an   Internet   connection,   or   FALSE   otherwise.  
   
  Function   Information  
   
  Windows   NT   Use   version   4.0.   Implemented   only   as   an   ANSI   function.    
  Windows   Use   Windows   95   and   later.   Implemented   only   as   an   ANSI   function.    
  Header   Wininet.h    
  Import   library   Wininet.lib    
  Minimum   availability   Internet   Explorer   4.0    
   
   
  傳回值中有個INTERNET_CONNECTION_OFFLINE   判斷是不是離線的。  

 

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.