How to get the list of destinations mapped to my user? By destinations I mean network drives/locations.

Ashok Aravind S N 20 Reputation points
2024-09-25T09:05:47.9266667+00:00

Hi, I am currently trying to find a way to determine all the drives and network locations attached to my pc in cpp. For the Logical Drives I can use GetLogicalDrives(), I am looking for ways to get the list of network locations added. So, far I have found the list at these 2 places. 1. $env:APPDATA\Microsoft\Windows\Network Shortcuts

Image

  1. HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\MountPoints2 and access using ***RegOpenKeyEx() *** and RegEnumKeyEx().

Which is the recommended way of doing this? In the first option I need to resolve the shortcut to get what is connected. In the second I need to read from the registry

Windows for business | Windows Client for IT Pros | User experience | Other
Developer technologies | C++
Developer technologies | C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
0 comments No comments
{count} votes

Answer accepted by question author
  1. Castorix31 91,191 Reputation points
    2024-09-25T14:56:56.7233333+00:00

    From MSDN, https://learn.microsoft.com/en-us/windows/win32/shell/knownfolderid

    %APPDATA%\Microsoft\Windows\Network Shortcuts is

    FOLDERID_NetHood

    By enumerating items from SHGetKnownFolderPath & FOLDERID_NetHood (IShellFolder, IEnumIDList, ...), I get shortcuts on my Windows 10 OS (I just added 1 shortcut to test)

    1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Anonymous
    2024-09-26T07:47:46.82+00:00

    Hello Ashok Aravind S N,

    Thank you for posting in Q&A forum.

    You could try to use Powershell cmdlet Get-PSDrive or net use cmd to get the list, here is the link for you reference:

    https://shellgeek.com/how-to-get-mapped-network-drives-using-powershell/

    I hope the information above is helpful.

    If you have any questions or concerns, please feel free to let us know.

    Best Regards,

    Daisy Zhou

    ============================================

    If the Answer is helpful, please click "Accept Answer" and upvote it.

    1 person found this answer helpful.

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.