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

<p>To find out if it's shared, I can use <a href="https://learn.microsoft.com/en-us/windows/desktop/api/Lmshare/nf-lmshare-netsharecheck" rel="nofollow noreferrer">NetShareCheck</a>.</p>

<p>How do I then map the drive to its share name? I thought that <a href="https://learn.microsoft.com/en-us/windows/desktop/api/Lmshare/nf-lmshare-netsharegetinfo" rel="nofollow noreferrer">NetShareGetInfo</a> would do it, but it looks like that takes the share name, not the local drive name, as an input.</p>

[{'answer_id': 12599, 'author': 'Stu', 'author_id': 414, 'author_profile': 'https://Stackoverflow.com/users/414', 'pm_score': 3, 'selected': True, 'text': '<p>If all else fails, you could always use <a href="https://learn.microsoft.com/en-us/windows/win32/api/lmshare/nf-lmshare-netshareenum" rel="nofollow noreferrer">NetShareEnum</a> and call <a href="https://learn.microsoft.com/windows/desktop/api/lmshare/nf-lmshare-netsharegetinfo" rel="nofollow noreferrer">NetShareGetInfo</a> on each.</p>\n'}, {'answer_id': 12634, 'author': 'Andrew Grant', 'author_id': 1043, 'author_profile': 'https://Stackoverflow.com/users/1043', 'pm_score': 0, 'selected': False, 'text': "<p>Use;</p>\n\n<pre><code>SHGetFileInfo with SHGFI_ATTRIBUTES\n</code></pre>\n\n<p>upon return check the dwAttributes flag for SFGAO_SHARE.</p>\n\n<p>I'm not sure how to find the actual path tho.</p>\n"}, {'answer_id': 12958, 'author': 'Joel Lucsy', 'author_id': 645, 'author_profile': 'https://Stackoverflow.com/users/645', 'pm_score': 1, 'selected': False, 'text': '<p>I believe you\'re looking for <a href="https://learn.microsoft.com/en-us/windows/win32/api/winnetwk/nf-winnetwk-wnetgetconnectiona" rel="nofollow noreferrer">WNetGetConnectionA</a> or <a href="https://learn.microsoft.com/en-us/windows/win32/api/winnetwk/nf-winnetwk-wnetgetconnectionw" rel="nofollow noreferrer">WNetGetConnectionW</a>.</p>\n'}]
['https://Stackoverflow.com/questions/12594', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/179/']