I am mounting a network drive to windows using WNetAddConnection2 which is working fine but while mounting the drive by default it assigns the name as Server IP and FolderName ,
NDSTestFolder on 'NAS server (172.24.17.116)'(R:)
I need to rename the drive label using SetVolumeLabel but this fails for the network drive saying invalid parameter while SetVolumeLabel works fine for the local drives.
Is there a way I can rename or relabel a network drive? So that I can change
NDSTestFolder on 'NAS server (172.24.17.116)'(R:)
to
NDS@MyFolder (R:)
Not sure if there's an API for this but the strings are stored in the registry under:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\MountPoints2
Find the correct subkey by parsing the keys there (it will probably look like "##172.24.17.116#NDSTestFolder" ) and change the _LabelFromReg value to whatever you like...
I tried using vb script for renaming thr drive:
Translated your script into C++: