看到强横的美国现在到处横行霸道……真是令人气愤
吾辈当努力学习科学文化知识,学习美国最好的技术将来对付这个中国未来的敌人!
等全部转化完毕后,有意者跟我联系吧!
里面有可以解决你问题的函数!!!需要DEMO也可以跟我联系!
unit IPHLPAPI;
//------------------------------------------------------------------------------
// 部分转化自IPHLPAPI.DLL(IP-Helper API)
// 改良自:嘟嘟猫 ddt_2k2@163.com
//------------------------------------------------------------------------------
interface
uses
Windows, winsock;
//------------- 从Microsoft IPTYPES.H文件转化--------------------------------
const
ANY_SIZE = 1;
MAX_ADAPTER_DESCRIPTION_LENGTH = 128; // arb.
MAX_ADAPTER_NAME_LENGTH = 256; // arb.
MAX_ADAPTER_ADDRESS_LENGTH = 8; // arb.
DEFAULT_MINIMUM_ENTITIES = 32; // arb.
MAX_HOSTNAME_LEN = 128; // arb.
MAX_DOMAIN_NAME_LEN = 128; // arb.
MAX_SCOPE_ID_LEN = 256; // arb.
//节点类型 ( NETBIOS)
BROADCAST_NODETYPE = 1;
PEER_TO_PEER_NODETYPE = 2;
MIXED_NODETYPE = 4;
HYBRID_NODETYPE = 8;
NETBIOSTypes : array[0..8] of string[20] =
( 'UNKNOWN', 'BROADCAST', 'PEER_TO_PEER', '', 'MIXED', '', '', '', 'HYBRID'
);
//适配器类型
IF_OTHER_ADAPTERTYPE = 0;
IF_ETHERNET_ADAPTERTYPE = 1;
IF_TOKEN_RING_ADAPTERTYPE = 2;
IF_FDDI_ADAPTERTYPE = 3;
IF_PPP_ADAPTERTYPE = 4;
IF_LOOPBACK_ADAPTERTYPE = 5;
IF_SLIP_ADAPTERTYPE = 6;
//
AdaptTypes : array[0..6] of string[10] =
( 'other', 'ethernet', 'tokenring', 'FDDI', 'PPP', 'loopback', 'SLIP' );
//-----从其他MS头文件取得的信息---------------------------------------
MAX_INTERFACE_NAME_LEN = 256; { mrapi.h }
MAXLEN_PHYSADDR = 8; { iprtrmib.h }
MAXLEN_IFDESCR = 256; { --"--- }
//------------------------------------------------------------------------------
type
TMacAddress = array[1..MAX_ADAPTER_ADDRESS_LENGTH] of byte;
//------IP地址结构---------------------------------------------------
PTIP_ADDRESS_STRING = ^TIP_ADDRESS_STRING;
TIP_ADDRESS_STRING = array[0..15] of char; // IP as xxx.xxx.xxx.xxx string
//
PTIP_ADDR_STRING = ^TIP_ADDR_STRING;
TIP_ADDR_STRING = packed record // for use in linked lists
Next : PTIP_ADDR_STRING;
IpAddress : TIP_ADDRESS_STRING;
IpMask : TIP_ADDRESS_STRING;
Context : DWORD;
end;
//--------固定信息结构---------------------------------------------
PTFixedInfo = ^TFixedInfo;
TFixedInfo = packed record
HostName : array[0..MAX_HOSTNAME_LEN + 4] of Char;
DomainName : array[0..MAX_DOMAIN_NAME_LEN + 4] of Char;
CurrentDNSServer : PTIP_ADDR_STRING;
DNSServerList : TIP_ADDR_STRING;
NodeType : UINT;
ScopeID : array[0..MAX_SCOPE_ID_LEN + 4] of char;
EnableRouting : UINT;
EnableProxy : UINT;
EnableDNS : UINT;
end;
//--------界面结构------------------------------------------------
PTMibIfRow = ^TMibIfRow;
TMibIfRow = packed record
wszName : array[1..MAX_INTERFACE_NAME_LEN] of WCHAR;
dwIndex : DWORD;
dwType : DWORD;
dwMTU : DWORD;
dwSpeed : DWORD;
dwPhysAddrLen : DWORD;
bPhysAddr : array[1..MAXLEN_PHYSADDR] of byte;
dwAdminStatus : DWORD;
dwOperStatus : DWORD;
dwLastChange : DWORD;
dwInOctets : DWORD;
dwInUcastPkts : DWORD;
dwInNUCastPkts : DWORD;
dwInDiscards : DWORD;
dwInErrors : DWORD;
dwInUnknownProtos : DWORD;
dwOutOctets : DWORD;
dwOutUCastPkts : DWORD;
dwOutNUCastPkts : DWORD;
dwOutDiscards : DWORD;
dwOutErrors : DWORD;
dwOutQLen : DWORD;
dwDescrLen : DWORD;
bDescr: array[1..MAXLEN_IFDESCR] of char; //byte;
end;
TMIBIfArray = array of TMIBIFRow;
//
PTMibIfTable = ^TMIBIfTable;
TMibIfTable = packed record
dwNumEntries : DWORD;
Table : array[0..ANY_SIZE - 1] of TMibIfRow;
end;
//------适配器信息结构-------------------------------------------------
TTIME_T = array[1..325] of Byte; //MS time.h 无此结构
PTIP_ADAPTER_INFO = ^TIP_ADAPTER_INFO;
TIP_ADAPTER_INFO = packed record
Next : PTIP_ADAPTER_INFO;
ComboIndex : DWORD;
AdapterName : array[1..MAX_ADAPTER_NAME_LENGTH + 4] of char;
Description : array[1..MAX_ADAPTER_DESCRIPTION_LENGTH + 4] of char;
AddressLength : UINT;
Address : array[1..MAX_ADAPTER_ADDRESS_LENGTH] of byte;
Index : DWORD;
aType : UINT;
DHCPEnabled : UINT;
CurrentIPAddress : PTIP_ADDR_STRING;
IPAddressList : TIP_ADDR_STRING;
GatewayList : TIP_ADDR_STRING;
DHCPServer : TIP_ADDR_STRING;
HaveWINS : BOOL;
PrimaryWINSServer : TIP_ADDR_STRING;
SecondaryWINSServer: TIP_ADDR_STRING;
LeaseObtained : TTIME_T; //?
LeaseExpires : TTIME_T; //?
end;
//----------------TCP结构------------------------------------------------
PTMibTCPRow = ^TMibTCPRow;
TMibTCPRow = packed record
dwState : DWORD;
dwLocalAddr : DWORD;
dwLocalPort : DWORD;
dwRemoteAddr: DWORD;
dwRemotePort: DWORD;
end;
//
PTMibTCPTable = ^TMibTCPTable;
TMibTCPTable = packed record
dwNumEntries : DWORD;
Table : array[0..0] of TMibTCPRow;
end;
//
PTMibTCPStats = ^TMibTCPStats;
TMibTCPStats = packed record
dwRTOAlgorithm : DWORD;
dwRTOMin : DWORD;
dwRTOMax : DWORD;
dwMaxConn : DWORD;
dwActiveOpens : DWORD;
dwPassiveOpens : DWORD;
dwAttemptFails : DWORD;
dwEstabResets : DWORD;
dwCurrEstab : DWORD;
dwInSegs : DWORD;
dwOutSegs : DWORD;
dwRetransSegs : DWORD;
dwInErrs : DWORD;
dwOutRsts : DWORD;
dwNumConns : DWORD;
end;
//---------UDP结构------------------------------------------------------
PTMibUDPRow = ^TMibUDPRow;
TMibUDPRow = packed record
dwLocalAddr : DWORD;
dwLocalPort : DWORD;
end;
//
PTMibUDPTable = ^TMIBUDPTable;
TMIBUDPTable = packed record
dwNumEntries : DWORD;
UDPTable : array[0..ANY_SIZE - 1] of TMibUDPRow;
end;
//
PTMibUdpStats = ^TMIBUdpStats;
TMIBUdpStats = packed record
dwInDatagrams : DWORD;
dwNoPorts : DWORD;
dwInErrors : DWORD;
dwOutDatagrams : DWORD;
dwNumAddrs : DWORD;
end;
//-----------IP结构 ------------------------------------------------------
//
PTMibIPNetRow = ^TMibIPNetRow;
TMibIPNetRow = packed record
dwIndex : DWORD;
dwPhysAddrLen : DWORD;
bPhysAddr : TMACAddress;
dwAddr : DWORD;
dwType : DWORD;
end;
//
PTMibIPNetTable = ^TMibIPNetTable;
TMibIPNetTable = packed record
dwNumEntries : DWORD;
Table : array[0..ANY_SIZE - 1] of TMibIPNetRow;
end;
//
PTMibIPStats = ^TMibIPStats;
TMibIPStats = packed record
dwForwarding : DWORD;
dwDefaultTTL : DWORD;
dwInReceives : DWORD;
dwInHdrErrors : DWORD;
dwInAddrErrors : DWORD;
dwForwDatagrams : DWORD;
dwInUnknownProtos : DWORD;
dwInDiscards : DWORD;
dwInDelivers : DWORD;
dwOutRequests : DWORD;
dwRoutingDiscards : DWORD;
dwOutDiscards : DWORD;
dwOutNoRoutes : DWORD;
dwReasmTimeOut : DWORD;
dwReasmReqds : DWORD;
dwReasmOKs : DWORD;
dwReasmFails : DWORD;
dwFragOKs : DWORD;
dwFragFails : DWORD;
dwFragCreates : DWORD;
dwNumIf : DWORD;
dwNumAddr : DWORD;
dwNumRoutes : DWORD;
end;
//
PTMibIPAddrRow = ^TMibIPAddrRow;
TMibIPAddrRow = packed record
dwAddr : DWORD;
dwIndex : DWORD;
dwMask : DWORD;
dwBCastAddr: DWORD;
dwReasmSize: DWORD;
Unused1, Unused2: WORD;
end;
TMibIPAddrArray = array of TMIBIPAddrRow;
//
PTMibIPAddrTable = ^TMibIPAddrTable;
TMibIPAddrTable = packed record
dwNumEntries : DWORD;
Table : array[0..ANY_SIZE - 1] of TMibIPAddrRow;
end;
//
PTMibIPForwardRow = ^TMibIPForwardRow;
TMibIPForwardRow = packed record
dwForwardDest : DWORD;
dwForwardMask : DWORD;
dwForwardPolicy : DWORD;
dwForwardNextHop : DWORD;
dwForwardIFIndex : DWORD;
dwForwardType : DWORD;
dwForwardProto : DWORD;
dwForwardAge : DWORD;
dwForwardNextHopAS: DWORD;
dwForwardMetric1 : DWORD;
dwForwardMetric2 : DWORD;
dwForwardMetric3 : DWORD;
dwForwardMetric4 : DWORD;
dwForwardMetric5 : DWORD;
end;
//
PTMibIPForwardTable = ^TMibIPForwardTable;
TMibIPForwardTable = packed record
dwNumEntries : DWORD;
Table : array[0..ANY_SIZE - 1] of TMibIPForwardRow;
end;
//--------ICMP结构----------------------------------------------------
PTMibICMPStats = ^TMibICMPStats;
TMibICMPStats = packed record
dwMsgs : DWORD;
dwErrors : DWORD;
dwDestUnreachs : DWORD;
dwTimeEcxcds : DWORD;
dwParmProbs : DWORD;
dwSrcQuenchs : DWORD;
dwRedirects : DWORD;
dwEchos : DWORD;
dwEchoReps : DWORD;
dwTimeStamps : DWORD;
dwTimeStampReps: DWORD;
dwAddrMasks : DWORD;
dwAddrReps : DWORD;
end;
PTMibICMPInfo = ^TMibICMPInfo;
TMibICMPInfo = packed record
InStats : TMibICMPStats;
OutStats : TMibICMPStats;
end;
//------------------从IPHLPAPI.DLL输入的API函数-----------------------------------
function GetAdaptersInfo( pAdapterInfo: PTIP_ADAPTER_INFO;
pOutBufLen: PULONG ): DWORD;
stdcall; external 'IPHLPAPI.DLL';
function GetNetworkParams( FixedInfo: PTFixedInfo; pOutPutLen: PULONG ): DWORD;
stdcall; external 'IPHLPAPI.DLL';
function GetTcpTable( pTCPTable: PTMibTCPTable; pDWSize: PDWORD;
bOrder: BOOL ): DWORD;
stdcall; external 'IPHLPAPI.DLL';
function GetTcpStatistics( pStats: PTMibTCPStats ): DWORD;
stdcall; external 'IPHLPAPI.DLL';
function GetUdpTable( pUdpTable: PTMibUDPTable; pDWSize: PDWORD;
bOrder: BOOL ): DWORD;
stdcall; external 'IPHLPAPI.DLL';
function GetUdpStatistics( pStats: PTMibUdpStats ): DWORD;
stdcall; external 'IPHLPAPI.DLL';
function GetIpStatistics( pStats: PTMibIPStats ): DWORD;
stdcall; external 'IPHLPAPI.DLL';
function GetIpNetTable( pIpNetTable: PTMibIPNetTable;
pdwSize: PULONG; bOrder: BOOL ): DWORD;
stdcall; external 'IPHLPAPI.DLL';
function GetIpAddrTable( pIpAddrTable: PTMibIPAddrTable;
pdwSize: PULONG; bOrder: BOOL ): DWORD;
stdcall; external 'IPHLPAPI.DLL';
function GetIpForwardTable( pIPForwardTable: PTMibIPForwardTable;
pdwSize: PULONG; bOrder: BOOL ): DWORD;
stdCall; external 'IPHLPAPI.DLL';
function GetIcmpStatistics( pStats: PTMibICMPInfo ): DWORD;
stdCall; external 'IPHLPAPI.DLL';
function GetRTTAndHopCount( DestIPAddress: DWORD; HopCount: PULONG;
MaxHops: ULONG; RTT: PULONG ): BOOL;
stdCall; external 'IPHLPAPI.DLL';
function GetIfTable( pIfTable: PTMibIfTable; pdwSize: PULONG;
bOrder: boolean ): DWORD;
stdCall; external 'IPHLPAPI.DLL';
function GetIfEntry( pIfRow: PTMibIfRow ): DWORD;
stdCall; external 'IPHLPAPI.DLL';
implementation
end.