Бывалый

Профиль
Группа: Участник
Сообщений: 164
Регистрация: 16.12.2006
Репутация: 9 Всего: 14
|
| Цитата | Искал подходящие функции wininet.dll, но ничего полезного не нашел :(
|
Полезное есть в iphlpapi.dll Мне хватило этих методов: | Код | public class Iphlpapi { #region defines
public const int MAX_ADAPTER_ADDRESS_LENGTH = 8; public const int MAX_ADAPTER_DESCRIPTION_LENGTH = 128; public const int MAX_ADAPTER_NAME_LENGTH = 256; public const int MAX_INTERFACE_NAME_LEN = 256;
public const int MAXLEN_IFDESCR = 256; public const int MAXLEN_PHYSADDR = 8; public const int MIB_IF_OPER_STATUS_CONNECTED = 4; public const int MIB_IF_OPER_STATUS_CONNECTING = 3; public const int MIB_IF_OPER_STATUS_DISCONNECTED = 2; public const int MIB_IF_OPER_STATUS_NON_OPERATIONAL = 0; public const int MIB_IF_OPER_STATUS_OPERATIONAL = 5; public const int MIB_IF_OPER_STATUS_UNREACHABLE = 1;
public const int MIB_IF_TYPE_ETHERNET = 6; public const int MIB_IF_TYPE_FDDI = 15; public const int MIB_IF_TYPE_LOOPBACK = 24; public const int MIB_IF_TYPE_OTHER = 1; public const int MIB_IF_TYPE_PPP = 23; public const int MIB_IF_TYPE_SLIP = 28; public const int MIB_IF_TYPE_TOKENRING = 9; public const int MIB_TCP_STATE_CLOSE_WAIT = 8;
public const int MIB_TCP_STATE_CLOSED = 1; public const int MIB_TCP_STATE_CLOSING = 9; public const int MIB_TCP_STATE_DELETE_TCB = 12; public const int MIB_TCP_STATE_ESTAB = 5; public const int MIB_TCP_STATE_FIN_WAIT1 = 6; public const int MIB_TCP_STATE_FIN_WAIT2 = 7; public const int MIB_TCP_STATE_LAST_ACK = 10; public const int MIB_TCP_STATE_LISTEN = 2; public const int MIB_TCP_STATE_SYN_RCVD = 4; public const int MIB_TCP_STATE_SYN_SENT = 3; public const int MIB_TCP_STATE_TIME_WAIT = 11; public const int NO_ERROR = 0; public static uint ERROR_NOT_SUPPORTED = 50;
#endregion #region AdaptersInfo
#region Nested type: IP_ADAPTER_INFO
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] public struct IP_ADAPTER_INFO { [MarshalAs(UnmanagedType.ByValTStr, SizeConst = MAX_ADAPTER_NAME_LENGTH + 4)] public string AdapterName;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = MAX_ADAPTER_ADDRESS_LENGTH)] public byte[] Address;
public uint AddressLength; public uint ComboIndex;
public IntPtr CurrentIpAddress;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = MAX_ADAPTER_DESCRIPTION_LENGTH + 4)] public string Description;
public bool DhcpEnabled;
public IP_ADDR_STRING DhcpServer; public IP_ADDR_STRING GatewayList; public bool HaveWins; public uint Index; public IP_ADDR_STRING IpAddressList; public int LeaseExpires; public int LeaseObtained; public IntPtr Next; public IP_ADDR_STRING PrimaryWinsServer; public IP_ADDR_STRING SecondaryWinsServer; public uint Type; } ;
#endregion #region Nested type: IP_ADDR_STRING
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] public struct IP_ADDR_STRING { public uint Context;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 4*4)] public string IpAddress;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 4*4)] public string IpMask;
public IntPtr Next; } ;
#endregion
#endregion #region IfTable
#region Nested type: MIB_IFROW
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] public struct MIB_IFROW { [MarshalAs(UnmanagedType.ByValArray, SizeConst = MAXLEN_IFDESCR)] public byte[] bDescr;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = MAXLEN_PHYSADDR)] public byte[] bPhysAddr;
public uint dwAdminStatus; public uint dwDescrLen; public uint dwIndex; public uint dwInDiscards; public uint dwInErrors; public uint dwInNUcastPkts; public uint dwInOctets; public uint dwInUcastPkts; public uint dwInUnknownProtos; public uint dwLastChange; public uint dwMtu; public uint dwOperStatus; public uint dwOutDiscards; public uint dwOutErrors; public uint dwOutNUcastPkts; public uint dwOutOctets; public uint dwOutQLen; public uint dwOutUcastPkts; public uint dwPhysAddrLen; public uint dwSpeed; public uint dwType;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = MAX_INTERFACE_NAME_LEN)] public string wszName; } ;
#endregion #region Nested type: MIB_IFTABLE
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] public struct MIB_IFTABLE { public uint dwNumEntries; public MIB_IFROW table; } ;
#endregion
#endregion #region TCP
#region Nested type: MIB_EXTCPROW
[StructLayout(LayoutKind.Sequential)] public struct MIB_EXTCPROW { public int dwLocalAddress; public int dwLocalPort; public int dwProcessId; public int dwRemoteAddress; public int dwRemotePort; public int dwState; } ;
#endregion #region Nested type: MIB_EXTCPTABLE
[StructLayout(LayoutKind.Sequential)] public struct MIB_EXTCPTABLE { public int dwNumEntries; public MIB_EXTCPROW table; }
#endregion #region Nested type: MIB_TCPROW
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] public struct MIB_TCPROW { public int dwLocalAddress; public int dwLocalPort; public int dwRemoteAddress; public int dwRemotePort; public int dwState; }
#endregion #region Nested type: MIB_TCPSTATS
[StructLayout(LayoutKind.Sequential)] public struct MIB_TCPSTATS { public int dwActiveOpens; public int dwAttemptFails; public int dwCurrEstab; public int dwEstabResets; public int dwInErrs; public int dwInSegs; public int dwMaxConn; public int dwNumConns; public int dwOutRsts; public int dwOutSegs; public int dwPassiveOpens; public int dwRetransSegs; public int dwRtoAlgorithm; public int dwRtoMax; public int dwRtoMin; }
#endregion #region Nested type: MIB_TCPTABLE
[StructLayout(LayoutKind.Sequential)] public struct MIB_TCPTABLE { public int dwNumEntries; public MIB_TCPROW table; }
#endregion
#endregion #region UDP
#region Nested type: MIB_EXUDPROW
[StructLayout(LayoutKind.Sequential)] public struct MIB_EXUDPROW { public int dwLocalAddress; public int dwLocalPort; public int dwProcessId; }
#endregion #region Nested type: MIB_EXUDPTABLE
[StructLayout(LayoutKind.Sequential)] public struct MIB_EXUDPTABLE { public int dwNumEntries; public MIB_EXUDPROW table; }
#endregion #region Nested type: MIB_UDPROW
[StructLayout(LayoutKind.Sequential)] public struct MIB_UDPROW { public int dwLocalAddress; public int dwLocalPort; }
#endregion #region Nested type: MIB_UDPSTATS
[StructLayout(LayoutKind.Sequential)] public struct MIB_UDPSTATS { public int dwInDatagrams; public int dwInErrors; public int dwNoPorts; public int dwNumAddrs; public int dwOutDatagrams; }
#endregion #region Nested type: MIB_UDPTABLE
[StructLayout(LayoutKind.Sequential)] public struct MIB_UDPTABLE { public int dwNumEntries; public MIB_UDPROW table; }
#endregion
#endregion #region API
[DllImport("kernel32.dll", EntryPoint = "CopyMemory")] public static extern void CopyMemory_IpAddrString( ref IP_ADDR_STRING Destination, byte[] Source, int Length );
[DllImport("kernel32.dll", EntryPoint = "CopyMemory")] public static extern void CopyMemory_IpAdapterInfo( ref IP_ADAPTER_INFO Destination, byte[] Source, int Length );
[DllImport("kernel32.dll", EntryPoint = "CopyMemory")] public static extern void CopyMemory_IpAdapterInfoPtr( ref IP_ADAPTER_INFO Destination, IntPtr Source, int Length );
[DllImport("kernel32.dll", EntryPoint = "CopyMemory")] public static extern void CopyMemory_Int( ref int Destination, ref byte Source, int Length );
[DllImport("kernel32.dll", EntryPoint = "CopyMemory")] public static extern void CopyMemory_MibIfRow( ref MIB_IFROW Destination, ref byte Source, int Length );
[DllImport("kernel32.dll", EntryPoint = "CopyMemory")] public static extern void CopyMemory_MibIfTable( ref MIB_IFTABLE Destination, byte[] Source, int Length );
[DllImport("kernel32.dll", EntryPoint = "CopyMemory")] public static extern void CopyMemory_MibTCPRow( ref MIB_TCPROW Destination, IntPtr Source, int Length );
[DllImport("kernel32.dll", EntryPoint = "CopyMemory")] public static extern void CopyMemory_MibExTCPRow( ref MIB_EXTCPROW Destination, IntPtr Source, int Length );
[DllImport("kernel32.dll", EntryPoint = "CopyMemory")] public static extern void CopyMemory_MibUDPRow( ref MIB_UDPROW Destination, IntPtr Source, int Length );
[DllImport("kernel32.dll", EntryPoint = "CopyMemory")] public static extern void CopyMemory_MibExUDPRow( ref MIB_EXUDPROW Destination, IntPtr Source, int Length );
[DllImport("iphlpapi.dll")] public static extern uint GetAdaptersInfo( byte[] pAdapterInfo, ref uint dwOutBufLen );
[DllImport("iphlpapi.dll")] public static extern uint GetIfTable( byte[] pIfTable, ref uint pdwSize, bool bOrder );
[DllImport("iphlpapi.dll", SetLastError = true)] public static extern int GetTcpStatistics( ref MIB_TCPSTATS pStats );
[DllImport("iphlpapi.dll", SetLastError = true)] public static extern int GetTcpTable( byte[] pTcpTable, out int pdwSize, bool bOrder );
[DllImport("iphlpapi.dll", SetLastError = true)] public static extern int GetUdpStatistics( ref MIB_UDPSTATS pStats );
[DllImport("iphlpapi.dll", SetLastError = true)] public static extern int GetUdpTable( byte[] UcpTable, out int pdwSize, bool bOrder );
[DllImport("iphlpapi.dll", SetLastError = true)] public static extern int AllocateAndGetTcpExTableFromStack( ref IntPtr pTcpExTable, bool bOrder, IntPtr hHeap, int dwZero, int dwFlags );
[DllImport("iphlpapi.dll", SetLastError = true)] public static extern int AllocateAndGetUdpExTableFromStack( ref IntPtr pUdpExTable, bool bOrder, IntPtr hHeap, int dwZero, int dwFlags );
[DllImport("iphlpapi.dll", SetLastError = true)] public static extern int SetTcpEntry( ref IntPtr pTcpRow );
[DllImport("iphlpapi.dll", SetLastError = true)] public static extern int SetTcpEntry( ref MIB_TCPROW pTcpRow );
[DllImport("kernel32.dll", SetLastError = true)] public static extern IntPtr GetProcessHeap();
#endregion }
|
Это сообщение отредактировал(а) Stepan_Lameroff - 23.7.2007, 20:18
|