在网上查了很久,好像不能直接调用 API 函数去修改。(有网友介绍 SetVolumLabel 函数可以修改,但是我尝试了一下没有成功)。后来我想尝试使用 脚本去修改无意中发现其实可以通过修改注册表修改。
注册表的位置:HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\MountPoints2\##192.168.22.200#student-1
修改键值 _LabelFromDesktopINI 即可。
在windows 中提供了一系列的注册表 API,也可以去 MSDN中查询这些API具体用法。简单的代码如下,框架是对的,但是具体用法要根据自己遇到的具体例子来修改。
std::string regedit;
fw::unicode_to_ascii(strsid, regedit);
regedit += "\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\MountPoints2\\##";
regedit += ip;(ip 是动态获得的)
regedit += "#";
regedit += name;(路径也是动