且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何检查地图网络驱动器连接?

更新时间:2023-11-28 10:07:34

IWshNetwork_Class 似乎是 Windows 脚本宿主对象模型 COM 库中的一个类.

将网络调暗为 IWshRuntimeLibrary.IWshNetwork_Class将驱动器调暗为 IWshRuntimeLibrary.IWshCollection_Class驱动器 = Network.EnumNetworkDrives对于 DriveCounter As Long = 0 To Drives.Count – 1 第 2 步MsgBox(Drives.Item(DriveCounter) & " 映射到 " & Drives.Item(DriveCounter + 1))下一个

查看此 PDF 了解更多信息...>

I want to check whether the network drive had map before I map the network drive. I use this code to map the drive.

 Dim network = New IWshNetwork_Class()

                network.MapNetworkDrive("Z:", ServerDc, Type.Missing, username, pwd)

IWshNetwork_Class appears to be a class in the Windows Script Host Object Model COM library.

Dim Network As IWshRuntimeLibrary.IWshNetwork_Class
Dim Drives As IWshRuntimeLibrary.IWshCollection_Class
Drives = Network.EnumNetworkDrives
For DriveCounter As Long = 0 To Drives.Count – 1 Step 2 
    MsgBox(Drives.Item(DriveCounter) & " is mapped to " & Drives.Item(DriveCounter + 1))
Next

Have a look at this PDF for more information...