WNetAddConnection2 返回 1219
我正在使用 WNetAddConnection2 和 WNetCancelConnection2 来映射或取消映射驱动器。
我想做的事情如下:
我在服务器(例如:myserver)上映射了一个文件夹(例如:Folder1)。所以路径是 \\myserver\Folder1,我将其映射到驱动器 X。
现在我想在同一个 myserver 上映射另一个文件夹(例如:Folder2)以编程方式驱动 Y。
当我在映射一个文件夹后调用 WNetAddConnection2 方法时,它返回 1219 而不是 0,并且出现错误:不允许同一用户使用多个用户名多次连接到服务器或共享资源。断开之前与服务器或共享资源的所有连接,然后重试。
我很困惑,因为我可以通过右键单击“我的电脑”并选择映射网络驱动器...来映射同一服务器上的“Folder2”,但不能以编程方式。
我是否遗漏了某些内容,或者我需要以不同的方式使用 NETRESOURCE 结构还是其他什么?
谢谢
I am using WNetAddConnection2 and WNetCancelConnection2 to map or unmap drives.
What i am trying to do is as follows:
I mapped a folder(eg:Folder1) on server(eg:myserver). so the path is \\myserver\Folder1 and i map it to drive X.
Now i want to map another folder(eg:Folder2) on same myserver to drive Y programmatically.
When i call the method WNetAddConnection2 after mapping one folder it returns 1219 instead of 0 and i get the error:Multiple connections to a server or shared resource by the same user, using more than one user name, are not allowed. Disconnect all previous connections to the server or shared resource and try again.
I am confused because i can map Folder2 on the same server by doing a right click on MyComputer and choosing map network drive..., but not programmatically.
Am i missing something or do i need to use the NETRESOURCE structure differently or anyhting else?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您是否也以编程方式映射 X: ?如果是这样,您在调用 WNetAddConnection2() 时是否使用相同的用户名和密码规范? 1219 错误表明您正在尝试使用不同的身份验证将多个驱动器映射到同一服务器。当使用相同的用户/密码组合时,我已成功将多个 WNetAddConnection2() 创建到同一服务器上的多个共享。
Are you mapping X: programmatically as well? If so are you using the same username and password specification in the calls to WNetAddConnection2()? The 1219 error would indicate that you are attempting to map multiple drives to the same server using different authentications. I have successfully made multiple WNetAddConnection2() to multiple shares on the same server when using the same user/pass combination.
如果其他人遇到此问题,我碰巧在资源管理器窗口中打开了有问题的文件共享,但没有意识到这一点。我关闭了窗口,然后代码运行良好。
In case anyone else has this issue, I happened to have the file share in question open in an Explorer window without realizing it. I closed the window and then the code worked fine.
回复很晚,但希望能有所帮助。我的做法是在C#中调用net delete命令。
////
////
Very late reply but hope can help. My way of doing is to call the net delete command in C#.
////
////