0
私は初心者のコーダーなので、知識がありません。私のばかげた質問に親切にお付き合いください。 GetNIC()とMakeStatic()ネームスペース交差点
GetNIC()System.Net.NetworkInformation名前空間を使用しています。 私はユーティリティ
私は2つのVB.NETの機能を持っているスイッチングIPアドレスを書いています。私はそれが現在のIPv4アダプタ、IP、DGW、SMと他の情報を見つけるために実行している。
MakeStatic()は、System.Management名前空間を使用します。私はGetNIC()からの情報を使用して、同じアダプタを外して情報を変更する方法を理解しようとしています。ここでは、IPを切り替えるためのコードの抜粋です。以前はManagementBaseObjectsを使用したことがなく、GetNIC()ですでに見つかったGUIDに一致するGUID(または何か)を見つける方法が不思議でした。
Dim objNewIP As ManagementBaseObject = Nothing
Dim objSetIP As ManagementBaseObject = Nothing
Dim objNewGate As ManagementBaseObject = Nothing
objNewIP = objMO.GetMethodParameters("EnableStatic")
objNewGate = objMO.GetMethodParameters("SetGateways")
'Set DefaultGateway
objNewGate("DefaultIPGateway") = New String() {Gateway}
objNewGate("GatewayCostMetric") = New Integer() {1}
'Set IPAddress and Subnet Mask
objNewIP("IPAddress") = New String() {IPAddress}
objNewIP("SubnetMask") = New String() {SubnetMask}
objSetIP = objMO.InvokeMethod("EnableStatic", objNewIP, Nothing)
objSetIP = objMO.InvokeMethod("SetGateways", objNewGate, Nothing)
基本的に私が撮影しています:
If objMO.<<something>> = NICguid then
<<<Do the above code>>
End IF