As show in Windows Resource Monitor:
I want to analyse network traffic of an application, but I dont know the Windows API. I used scapy or wireshark, but I don't know what data packages are this application.
So, I want to get the listening port first. But I don't know the API.

You can use
GetTcpTable2()orGetExtendedTcpTable()to enumerate open TCP ports, determining which ports are listeners, and get each one's owning process.You can use
GetExtendedUdpTable()to enumerate open UDP ports and get each one's owning process.