关键API:WSAEnumProtocols
关键结构体:LPWSAPROTOCOL_INFO
#include "TestEnumProtocor.h"
int main()
{
WSADATA wsadata;
LPWSAPROTOCOL_INFO lpProtocolInfo;
DWORD dword=0;
int nTotalProtocols;
int nRet=WSAStartup(MAKEWORD(2,0),&wsadata);
if (nRet!=0)
{
nRet =WSAGetLastError();
}
WSAEnumProtocols(NULL,lpProtocolInfo,&dword);
lpProtocolInfo=(LPWSAPROTOCOL_INFO)malloc(dword);
nTotalProtocols= WSAEnumProtocols(NULL,lpProtocolInfo,&dword);
for (int i=0;i<nTotalProtocols;i++)
{
OutputDebugString(lpProtocolInfo[i].szProtocol);
OutputDebugString("\n");
}
}