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
Windows
A family of Microsoft operating systems that run across personal computers, tablets, laptops, phones, internet of things devices, self-contained mixed reality headsets, large collaboration screens, and other devices.
5,376 questions
C++
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.
3,717 questions
0 comments No comments
{count} votes

Accepted answer
  1. Castorix31 85,116 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. Daisy Zhou 23,346 Reputation points Microsoft Vendor
    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 Answers by the question author, which helps users to know the answer solved the author's problem.