2

I have a NAS on my home network and it is mapped as drive K:. Sometimes the NAS is not ready as win starts up and the drive shows with red-"X" in File Explorer. If I click the drive with the X showing, it instantly displays the Folders, suggesting to me that it is now mapped but was not during the start up.

I have a very simple MP3 player I have written that believes the win red-X and not the actual status of the mapped drive, if that makes sense. If I click an MP3 file to play, it says the drive is not available. If I first click the drive in File Explorer, then the MP3 file, it works OK.

How can I add a "refresh" for that Mapped drive status in my MP3 player?

1 Answers1

0

I've seen someone suggested a scripted workarround for this - just try to access the path the drive is pointing to. If your drive Z: points to \\server\share then this may work (for use in batch script):

pushd \\server\share

Programmatically you can try to use WNetAddConnection2 with arguments that mirror your mapped drive's parameters. Sample algorithm:

  1. get connection status for the drive (WNetGetConnection)
  2. if the status is ERROR_CONNECTION_UNAVAIL then use WNetAddConnection2 to reconnect

Take a look at WNetRestoreConnectionW function in MSDN. There user Chesare has published on 1/14/2011 sample reconnect code (in C/C++).

p.s. All this is not tested but may work for you - try it ;)

iPath ツ
  • 2,468
  • 20
  • 31
  • 1
    Thanks, but nothing short of clicking the Mapped drive in File Explorer seems to work. –  May 09 '14 at 14:54