Windows/C++: How do I determine the share name associated with a shared drive?

China☆狼群 提交于 2019-12-13 02:34:58

问题


Let's say I have a drive such as C:\, and I want to find out if it's shared and what it's share name (e.g. C$) is.

To find out if it's shared, I can use NetShareCheck.

How do I then map the drive to its share name? I thought that NetShareGetInfo would do it, but it looks like that takes the share name, not the local drive name, as an input.


回答1:


If all else fails, you could always use NetShareEnum and call NetShareGetInfo on each.




回答2:


Use;

SHGetFileInfo with SHGFI_ATTRIBUTES

upon return check the dwAttributes flag for SFGAO_SHARE.

I'm not sure how to find the actual path tho.




回答3:


I believe you're looking for WNetGetConnection.



来源:https://stackoverflow.com/questions/12594/windows-c-how-do-i-determine-the-share-name-associated-with-a-shared-drive

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!