title: WinAPI: How can I list shares connected by a UNC Path
body: <p>Using a UNC path such as <code>\\1.2.3.4\drive\dir\myfile.txt</code> I can access files on a remote machine.
  I can make a connection using <a href="https://docs.microsoft.com/en-us/windows/win32/api/winnetwk/nf-winnetwk-wnetaddconnection2a" rel="nofollow noreferrer">WNetAddConnection2</a> programatically
  or I can just type <code>\\1.2.3.4\</code> in the explorer address bar, and then Windows will prompt me for user credentials etc.</p>
  <p>How can I list the UNC drives that the local machine is connected to for the current user?</p>
  <p>I tried <a href="https://docs.microsoft.com/en-us/windows/win32/wnet/enumerating-network-resources" rel="nofollow noreferrer">this</a> example using <a href="https://docs.microsoft.com/en-us/windows/win32/api/winnetwk/nf-winnetwk-wnetenumresourcea" rel="nofollow noreferrer">WNetEnumResource</a> - it lists nothing I find useful.</p>
  <p>I also found <a href="https://www.installsetupconfig.com/win32programming/networkmanagementapis16_41.html" rel="nofollow noreferrer">this</a> example using <a href="https://docs.microsoft.com/en-us/windows/win32/api/lmshare/nf-lmshare-netshareenum" rel="nofollow noreferrer">NetShareEnum</a>, but it seems only to list who is connected to a specified remote machine.</p>
  <p>I want to list all UNC drives that the local machine is connected to (which must not have necessarily have a local drive letter).
  How can that be done?</p>