I'm trying to write a program, that adds a network connection with WNetAddConnection2()
and then renames the newly created network drive.
The only way I found to do it, is either with PowerShell, or manually editing the registry.
The PowerShell way might be ok for C++ application, but my application has to be in C.
The registry edit was the former way how I renamed the folder, but when my application is run as a system service, modifying HKCU
is not trivial.
Even if I modify the registry, I have to modify it per user, which doesn't change the label for new users.
This is the batch script I used previously to change the label:
REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\MountPoints2\##computername#sharename" /v "_LabelFromReg" /t REG_SZ /d "label" /f
For some reason calling SetVolumeLabel()
doesn't work at all.
Is there any other way to do this? Or at least some recommended way to change the registry for all users?