我想将此 VBScript 编写为 VB.NET。但它不起作用....这是我的VBScript:
'VBScript
Dim strServer
strServer = "LP-BK"
Set objConnection = GetObject("WinNT://" & strServer & "/LanmanServer")
Set colSessions = objConnection.Sessions
on error resume next
For Each objSession in colSessions
Msgbox("objSession Computer is: " & objSession.Computer)
Msgbox("objSession User is: " & objSession.User)
Next
Set objConnection = nothing
Set ColResources = nothing
Set colSessions = nothing
这是我的 VB.Net 代码,它不起作用。
'Imports ActiveDs
'and add a reference on the com tab to Active DS Type Library
Private Sub bSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bSave.Click
Dim fso As IADsFileServiceOperations
On Error GoTo Cleanup
fso = GetObject("WinNT://LP-BK/LanmanServer") ' There is a error: Option Strict On disallows implicit conversions from 'Object' to 'ActiveDs.IADsFileServiceOperations'.
For Each session In fso.Sessions
MsgBox(session.Computer) ' Error: Option Strict On disallows late binding.
Next
Cleanup:
If (Err.Number <> 0) Then
MsgBox("An error has occurred. " & Err.Number)
End If
fso = Nothing
End Sub
我希望你能帮助我......非常感谢提前问候
编辑:有人知道吗?