// TcpPid.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <winsock2.h>
#include <ws2tcpip.h>
#include <iphlpapi.h>
#include <iostream>
#include <iomanip>
using namespace std;
#pragma comment(lib, "iphlpapi.lib")
#pragma comment(lib, "ws2_32.lib")
#define MALLOC(x) HeapAlloc(GetProcessHeap(), 0, (x))
#define FREE(x) HeapFree(GetProcessHeap(), 0, (x))
int _tmain(int argc, _TCHAR* argv[])
{
PMIB_TCPTABLE_OWNER_PID ptTable;
DWORD dwSize = { 0 };
DWORD dwRetValue = { 0 };
struct in_addr inAddr;
static char TcpState[][32] =
{
"???",
"CLOSED",
"LISTENING",
"SYN_SENT",
"SEN_RECEIVED",
"ESTABLISHED",
"FIN_WAIT",
"FIN_WAIT2",
"CLOSE_WAIT",
"CLOSING",
"LAST_ACK",
"TIME_WAIT"
};
ptTable= (MIB_TCPTABLE_OWNER_PID*)MALLOC(sizeof(MIB_TCPTABLE_OWNER_PID));
dwSize = sizeof(MIB_TCPTABLE);
if ((dwRetValue = GetExtendedTcpTable(ptTable, &dwSize, TRUE, AF_INE
进程与网络(TCP) GetExtendedTcpTable
最新推荐文章于 2024-10-13 19:16:54 发布