增加禁用风速自动停止复选框

This commit is contained in:
2026-03-28 16:52:46 +08:00
parent 8c3b67ca9f
commit 7385079afe
6 changed files with 25 additions and 17 deletions

View File

@@ -74,18 +74,20 @@ Public Class NetworkHelp
End Function
Public Shared Sub SetNetworkAdapterDHCP()
Public Shared Sub SetNetworkAdapterDHCP(Optional isetDHCP As Boolean = True)
Dim mc As ManagementClass = New ManagementClass("Win32_NetworkAdapterConfiguration")
Dim moc As ManagementObjectCollection = mc.GetInstances()
If isetDHCP Then
For Each mo As ManagementObject In moc
If Not CBool(mo("IPEnabled")) Then Continue For
mo.InvokeMethod("SetDNSServerSearchOrder", Nothing)
mo.InvokeMethod("EnableStatic", Nothing)
mo.InvokeMethod("SetGateways", Nothing)
mo.InvokeMethod("EnableDHCP", Nothing)
Exit For
Next
End If
For Each mo As ManagementObject In moc
If Not CBool(mo("IPEnabled")) Then Continue For
mo.InvokeMethod("SetDNSServerSearchOrder", Nothing)
mo.InvokeMethod("EnableStatic", Nothing)
mo.InvokeMethod("SetGateways", Nothing)
mo.InvokeMethod("EnableDHCP", Nothing)
Exit For
Next
End Sub
End Class