映射网络驱动器 (API)






4.64/5 (61投票s)
用于与“映射网络驱动器”Windows 接口交互的类
它做什么?
这是一个用于与 Windows 映射网络驱动器 API 交互的类。
类简介...
入门
将类文件 "cNetworkDrives0015.cs" 添加到您的项目 / 解决方案中。
在您的窗体等中添加 "using" 定义。
using aejw.Network;
示例 (映射网络驱动器)
NetworkDrive oNetDrive = new aejw.Network.NetworkDrive(); try{ oNetDrive.LocalDrive = "m:"; oNetDrive.ShareName = "\\ComputerName\Share" oNetDrive.MapDrive(); }catch(Exception err){ MessageBox.Show(this,"Error: "+err.Message); } oNetDrive = null;
示例 (取消映射网络驱动器)
NetworkDrive oNetDrive = new aejw.Network.NetworkDrive(); try{ oNetDrive.LocalDrive = "m:"; oNetDrive.UnMapDrive(); }catch(Exception err){ MessageBox.Show(this,"Error: "+err.Message); } oNetDrive = null;
用户名和密码函数...
以下示例需要声明对象 / 类。 cNetworkDrive oNetDrive = new cNetworkDrive();
映射网络驱动器
//Map drive with current user credentials oNetDrive.LocalDrive = "m:"; oNetDrive.ShareName = "\\ComputerName\Share1" oNetDrive.MapDrive();
//Map drive with specified user credentials oNetDrive.LocalDrive = "m:"; oNetDrive.ShareName = "\\ComputerName\Share1" oNetDrive.MapDrive("Bob_Username","Bob_Password");
//Map drive with and prompt user for credentials oNetDrive.LocalDrive = "m:"; oNetDrive.ShareName = "\\ComputerName\Share1" oNetDrive.PromptForCredentials = true; oNetDrive.MapDrive();
//Map drive using a persistent connection oNetDrive.LocalDrive = "m:"; oNetDrive.Persistent = true; oNetDrive.SaveCredentials = true; oNetDrive.ShareName = "\\ComputerName\Share1" oNetDrive.MapDrive("Bob_Username","Bob_Password");
取消映射网络驱动器
//Unmap a network connection oNetDrive.LocalDrive = "m:"; oNetDrive.ShareName = "\\ComputerName\Share1" oNetDrive.UnMapDrive();
//Unmap a network connection ignoring network related errors oNetDrive.LocalDrive = "m:"; oNetDrive.Force = true; oNetDrive.ShareName = "\\ComputerName\Share1" oNetDrive.UnMapDrive();
其他功能
//Display windows connection dialog oNetDrive.ShowConnectDialog(this); //Display windows disconnection dialog oNetDrive.ShowDisconnectDialog(this);
//Restore all persistent connections oNetDrive.RestoreDrives();
历史
- 2004 年 5 月 14 日 - build0015
LocalDrive
和ShareName
现在是属性。- 对话框函数现在使用窗体对象而不是窗口句柄。
- 公共函数和属性的重命名方案,
MapNetworkDrive(...)
现在是MapDrive(...)
,等等... - 添加了
Persistant
选项,用于在登录时重新连接驱动器。 - 添加了
SaveCredentials
选项,允许 Windows 记住用户凭据以重新连接持久连接。 - 添加了
Force
选项,用于MapDrive
调用,如果驱动器已连接,它将断开该驱动器,然后重新连接到新的共享。 - 添加了
PromptForCredintals
选项,用于MapDrive
调用,Windows 将要求提供用于连接的用户名和密码。 - 添加了
RestoreDrives
函数,用于恢复持久连接。
- 2004 年 4 月 30 日 - build0012
- 代码改进和整理,添加了类注释。
- 2004 年 4 月 27 日 - build0011
- 调整了声明标签,整理了类和文章
- 2004 年 4 月 26 日 - build0010
- 首次在线发布版本