Come creare un servizio di collegamento
Un'altra attività che può essere eseguita durante la configurazione di una connessione IPDLC consiste nel creare il servizio di collegamento.
Per creare un servizio di collegamento
Connettersi allo spazio dei nomi nel computer locale usando GetObject.
Creare la nuova istanza del servizio di collegamento usando SpawnInstance.
Impostare le proprietà del nuovo servizio di collegamento.
Eseguire il commit della nuova istanza in memoria usando il metodo Put_ .
L'esempio seguente illustra come creare un nuovo servizio di collegamento:
private Sub CreateIPDLCLinkService
on error resume next
' Connect to the namepsace on the local machine
Set Namespace = GetObject("Winmgmts:root\MicrosoftHIS")
Set ObjClass = Namespace.Get("MsSna_LinkService_IpDlc")
' Create new link service instance
Set NewInst = ObjClass.SpawnInstance_
' Set instance properties
NewInst.NetworkName = Left(strComputerName, 8)
NewInst.CPName = "IPDLCLS"
NewInst.NodeID = "05D.FFFFF"
NewInst.AddressType = 2
NewInst.LocalAddress = Trim(strLocalAddress)
NewInst.LENNode = strLenNode
NewInst.PrimaryNNS = strPrimaryNNS
if (strBackupNNS <> Empty) then
NewInst.BackupNNS = strBackupNNS
end if
' Commit the instance
NewInst.Put_
if Err.Number <> 0 then
PrintWMIErrorThenExit Err.Description, Err.Number
Wscript.Echo "Link Service Creation Failed " & Err.Description
Else
Wscript.Echo "Link Serice Created Successfully"
end if
End Sub