WNetAddConnection2() 和 NetUseAdd() 之间的区别
我正在本地安装远程驱动器(请参阅 GetVolumeNameForVolumeMountPoint 的用户/密码问题()(Windows 远程驱动器安装?))
问题:有什么区别WNetAddConnection2()
和 NetUseAdd()
? 它们似乎都允许您将远程驱动器路径分配给提供用户名和密码的本地驱动器号。
此外,我可以调用 WNetAddConnection2()
指定本地驱动器号(有效),或为本地驱动器号指定“NULL”,控制台 net use
命令将显示正如您所期望的那样,成功将远程驱动器安装到本地“无”,但我不确定这种结果的目的。我希望它能够在本地系统/进程和远程计算机之间建立“登录凭据”,以便对 ::GetVolumeNameForVolumeMountPoint()
的其他调用将具有正确的用户名/密码上下文,但这并没有不为我工作。
最终目标是在本地安装远程驱动器而无需本地驱动器号(例如本地 GUID 路径共享,因为所有 26 个本地驱动器号都已在使用中),但对 的所有调用::GetVolumeNameForVolumeMountPoint()
失败,并显示 登录失败:未知的用户名或错误密码
,即使我成功远程挂载到提供远程用户名和密码的本地驱动器号(当前使用WNetAddConnection2()
)。
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()
).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
NetUseAdd()
使连接在 Windows 资源管理器中可见,而WNetUseConnection()
和WNetAddConnection()
不使连接在 Windows 资源管理器中可见。NetUseAdd()
makes the connection visible in Windows Explorer, whileWNetUseConnection()
andWNetAddConnection()
do not make the connection visible in Windows Explorer.