Convert mapped drive to UNC

Discussion about anything that might be of interest to MediaMonkey users.

Moderator: Gurus

hostonmark
Posts: 2
Joined: Mon May 03, 2010 11:25 am

Re: Convert mapped drive to UNC

Post by hostonmark »

This is very simple.A call to WNetGetConnection API returns the UNC name for any drive letter, most drives typically are not mapped.

I've put together a loop that calls a DriveLetterToUNC function on each letter of the alphabet from C to Z,prepares an adequate buffer by creating a string that's MAX_PATH characters long, then passes this string with the buffer length and drive letter to WNetGetConnection.

Your code extracts the UNC name from the buffer by scanning for the first Null character and trimming just before it.
Post Reply