您现在的位置:首页 >> 网络通讯 >> 网络通讯 >> 内容

Delphi中获取网络类型

时间:2011/9/3 15:12:51 点击:

  核心提示:uses WinInet; const MODEM = 1; LAN = 2; PROXY = 4; BUSY = 8;function GetConnectionKind(var strKind:...
uses 
  WinInet; 

const 
  MODEM = 1; 
  LAN = 2; 
  PROXY = 4; 
  BUSY = 8;

function GetConnectionKind(var strKind: string): Boolean; 
var 
  flags: DWORD; 
begin 
  strKind := ''; 
  Result := InternetGetConnectedState(@flags, 0); 
  if Result then 
  begin 
    if (flags and MODEM) = MODEM then strKind := 'Modem'; 
    if (flags and LAN) = LAN then strKind := 'LAN'; 
    if (flags and PROXY) = PROXY then strKind := 'Proxy'; 
    if (flags and BUSY) = BUSY then strKind := 'Modem Busy'; 
  end; 
end; 

//例子
procedure TForm1.Button1Click(Sender: TObject); 
var 
  strKind: string; 
begin 
  if GetConnectionKind(strKind) then 
    ShowMessage(strKind); 
end;

作者:网络 来源:转载
共有评论 0相关评论
发表我的评论
  • 大名:
  • 内容:
  • 盒子文章(www.2ccc.com) © 2022 版权所有 All Rights Reserved.
  • 沪ICP备05001939号