How to detect what applications connect to the internet?

  .net, c++, windows

How to detect which application connects to the internet on the device? I tried to use the Firewall API for this, as you can see below, but it only displays applications authenticated in the firewall, but in my case it needs applications (full file path) that are trying to connect to the Internet at the moment.

public ICollection GetAuthorizedAppPaths()
        if (!IsFirewallInstalled)
            throw new FirewallHelperException("Cannot remove authorization: Firewall is not installed.");
        ArrayList list = new ArrayList();
        foreach (INetFwAuthorizedApplication app in fwMgr.LocalPolicy.CurrentProfile.AuthorizedApplications)
        return list;

I have searched a lot of articles on the internet on this subject but unfortunately I could not find anything related to it.

Source: Windows Questions