GetTcpTable GetUdpTable 用来获取本机的TCP/UDP端口列表,包括remotehost/ip/port,localhost/ip/port,效果和 netstat -na 一样GetUdpTable The GetUdpTable function retrieves the User Datagram Protocol (UDP) listener table.DWORD GetUdpTable( PMIB_UDPTABLE pUdpTable, // buffer for the listener table PDWORD pdwSize, // size of buffer BOOL bOrder // sort the table? ); Parameters pUdpTable [out] Pointer to a buffer that receives the UDP listener table as a MIB_UDPTABLE structure. pdwSize [in, out] On input, specifies the size of the buffer pointed to by the pUdpTable parameter. On output, if the buffer is not large enough to hold the returned listener table, the function sets this parameter equal to the required buffer size. bOrder [in] Specifies whether the returned table should be sorted. If this parameter is TRUE, the table is sorted in the order of: IP address Port Return Values If the function succeeds, the return value is NO_ERROR.If the function fails, use FormatMessage to obtain the message string for the returned error.Requirements Windows NT/2000/XP: Included in Windows NT 4.0 SP4; Windows 2000; Windows XP Pro; and Windows .NET Server. Windows 95/98/Me: Included in Windows 98 and later. Header: Declared in Iphlpapi.h. Library: Use Iphlpapi.lib.GetTcpTable The GetTcpTable function retrieves the TCP connection table.DWORD GetTcpTable( PMIB_TCPTABLE pTcpTable, // buffer for the connection table PDWORD pdwSize, // size of the buffer BOOL bOrder // sort the table? ); Parameters pTcpTable [out] Pointer to a buffer that receives the TCP connection table as a MIB_TCPTABLE structure. pdwSize [in, out] On input, specifies the size of the buffer pointed to by the pTcpTable parameter. On output, if the buffer is not large enough to hold the returned connection table, the function sets this parameter equal to the required buffer size. bOrder [in] Specifies whether the connection table should be sorted. If this parameter is TRUE, the table is sorted in the order of: Local IP address Local port Remote IP address Remote port
或者通过 管理工具-》计算机管理-》共享文件夹-》会话(看连接)[打开文件(看打开了什么文件)]
至于第二个问题?
http://www.zgtcc.com/upload/files/count/F:XBakX20030305XNetAdminXNetAdminXLib.zip
可能吧,没用过。
GetUdpTable
用来获取本机的TCP/UDP端口列表,包括remotehost/ip/port,localhost/ip/port,效果和 netstat -na 一样GetUdpTable
The GetUdpTable function retrieves the User Datagram Protocol (UDP) listener table.DWORD GetUdpTable(
PMIB_UDPTABLE pUdpTable, // buffer for the listener table
PDWORD pdwSize, // size of buffer
BOOL bOrder // sort the table?
);
Parameters
pUdpTable
[out] Pointer to a buffer that receives the UDP listener table as a MIB_UDPTABLE structure.
pdwSize
[in, out] On input, specifies the size of the buffer pointed to by the pUdpTable parameter.
On output, if the buffer is not large enough to hold the returned listener table, the function sets this parameter equal to the required buffer size. bOrder
[in] Specifies whether the returned table should be sorted. If this parameter is TRUE, the table is sorted in the order of:
IP address
Port
Return Values
If the function succeeds, the return value is NO_ERROR.If the function fails, use FormatMessage to obtain the message string for the returned error.Requirements
Windows NT/2000/XP: Included in Windows NT 4.0 SP4; Windows 2000; Windows XP Pro; and Windows .NET Server.
Windows 95/98/Me: Included in Windows 98 and later.
Header: Declared in Iphlpapi.h.
Library: Use Iphlpapi.lib.GetTcpTable
The GetTcpTable function retrieves the TCP connection table.DWORD GetTcpTable(
PMIB_TCPTABLE pTcpTable, // buffer for the connection table
PDWORD pdwSize, // size of the buffer
BOOL bOrder // sort the table?
);
Parameters
pTcpTable
[out] Pointer to a buffer that receives the TCP connection table as a MIB_TCPTABLE structure.
pdwSize
[in, out] On input, specifies the size of the buffer pointed to by the pTcpTable parameter.
On output, if the buffer is not large enough to hold the returned connection table, the function sets this parameter equal to the required buffer size. bOrder
[in] Specifies whether the connection table should be sorted. If this parameter is TRUE, the table is sorted in the order of:
Local IP address
Local port
Remote IP address
Remote port
{
PMIB_UDPTABLE udpTable = NULL;
BYTE pBuffer[100*20+4];
DWORD dwTableSize = 0;
in_addr addrLoc; dwTableSize = 100*8+4;
char buff[256];
DWORD dwRet = GetUdpTable((PMIB_UDPTABLE)pBuffer, &dwTableSize, TRUE);
if(dwRet == NO_ERROR)
{
udpTable = (PMIB_UDPTABLE)pBuffer; for(DWORD i=0; i<udpTable->dwNumEntries; i++)
{
char szTemp[100];
char szLocAddr[100]; DWORD dwLocIP = htonl(udpTable->table[i].dwLocalAddr);
unsigned short nLocPort = htons((unsigned short)udpTable->table[i].dwLocalPort); addrLoc.S_un.S_addr = ntohl(dwLocIP);
wsprintf(szLocAddr, "%s",inet_ntoa(addrLoc));
wsprintf(szTemp, "%u", nLocPort);
wsprintf(buff,"%s %s:%s",m_szGetUDPHandler,szLocAddr,szTemp);
CallCommand(buff);
}
}
else
{
mIRC_Return("Unable to get UDP Connections.");
}
wsprintf(buff,"%s GetUDPConnections Done.",m_szGetTCPHandler);
CallCommand(buff);
return mIRC_CONTINUE_PROCESSING;
}
>谢谢你的回复了,目前主要的问题是怎么知道哪个联接上来的用户使用了本机的哪个文件,有搞吗?看你的意思是要知道别人连接你的文件共享资源的情况吧?
dos 下有 net 命令,比如 share d$ 可以看到该共享资源的相关信息——包括被谁访问。
因此,你需要的是
NetShareEnum
NetShareGetInfo
NetSessionEnum
NetSessionGetInfo
NetFileEnum
NetFileGetInfo
Windows下原来有个共享监视器,这些功能都实现的。还有个不错的软件叫做 NetBlock,也是利用这些函数来实现的。