开发者

Setting the label for a Windows networking mapping

Is it possible to give a network drive mapping (as created with the WNetAddConnection functions or "Map network drive..." GUI) a label other than the default "<Target Name> (<Target Path>) (<Drive Letter>:)" one?

I tried giving SetVolumeLabel a go but this always fails, and开发者_JS百科 I see nothing in the WNet API's to specficy the display label.


This isn't a 100% solution but it's more of an answer than a comment...

If you rename a mapped network drive the the GUI (by right clicking on it and going to 'Rename') it adds a value to the registry. Reading round on various sites (notably this one) it looks like Windows may sporadically delete this value by itself, so this may not be a permanent solution...

I have just manually done it through regedit and it worked in the GUI, so I see no reason why it shouldn't work programmatically as well

Add a string value called _LabelFromReg with a value of whatever you want the label to be to the registry key

HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\MountPoints2\##<server-name>#<share-name>

This key should already exist if you have already created the share.

Apparently (see the link above) you then need to make that key read-only to prevent the OS from changing it back at will - I don't know how you would do that programmatically but i'm sure it can be done.

I know there are huge gaps in this answer, but maybe it's a poke in the right direction?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜