Isaac Moses
Isaac Moses

Reputation: 1609

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

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.

Upvotes: 1

Views: 1739

Answers (3)

Joel Lucsy
Joel Lucsy

Reputation: 8706

I believe you're looking for WNetGetConnectionA or WNetGetConnectionW.

Upvotes: 1

Stu
Stu

Reputation: 15769

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

Upvotes: 3

Andrew Grant
Andrew Grant

Reputation: 58796

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.

Upvotes: 0

Related Questions