7

I'm mounting a remote drive locally (see User/password problems with GetVolumeNameForVolumeMountPoint() (Windows remote drive mount?))

QUESTION: What is the difference between WNetAddConnection2() and NetUseAdd()? It appears they each permit you to assign a remote drive path to a local drive letter providing username and password.

Further, I can call WNetAddConnection2() specifying a local drive letter (works), or specifying "NULL" for the local drive letter, and the console net use command will show success mounting the remote drive to "nothing" locally -- as you would expect -- but I'm unsure of the purpose for that kind of result. My hope was that it would establish "logon credentials" between the local system/process and the remote computer so that other calls to ::GetVolumeNameForVolumeMountPoint() would have correct username/password context, but that doesn't work for me.

The ultimate goal is to mount the remote drive locally without a local drive letter (to something like a local GUID path share because all 26 local drive letters are already in use), but all calls to ::GetVolumeNameForVolumeMountPoint() fail with Logon failure: unknown user name or bad password, even after I successfully mount remotely to a local drive letter providing the remote username and password (currently using WNetAddConnection2()).

Community
  • 1
  • 1
charley
  • 5,913
  • 1
  • 33
  • 58
  • NetUseAdd- You could just pass null as the local drive letter, no local drive will be mapped and you can use unc path format to access the remote resource. – weeyoung Aug 31 '12 at 09:03
  • @weeyoung, that's no difference, works on both – Koen Dec 21 '12 at 14:39

1 Answers1

4

NetUseAdd() makes the connection visible in Windows Explorer, while WNetUseConnection() and WNetAddConnection() do not make the connection visible in Windows Explorer.

Alok Save
  • 202,538
  • 53
  • 430
  • 533
  • FYI, today I confirmed that the drive letters mounted with `WNetUseConnection2()` *are* visible through Windows Explorer (on Windows Vista). Weird. – charley Jul 05 '11 at 20:59
  • Unaccepted and confirmed, they both expose in Windows Explorer which is absolutely not what I want, if anyone would happen to have a solution to that, I would be happy to hear about it ;o) – Koen Dec 21 '12 at 14:40
  • @charley Where is there documentation for `WNetUseConnection2`? (Or did you mean `WNetAddConnection2`?) – Mike Lowery Nov 27 '18 at 22:53