Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between WNetAddConnection2() and NetUseAdd()

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()).

like image 909
charley Avatar asked Jul 02 '11 12:07

charley


1 Answers

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

like image 56
Alok Save Avatar answered Oct 09 '22 18:10

Alok Save