You need to use VB6 to read network card network management information and set it. So I found a piece of code that uses WMI's system query method to loop through all network adapters and obtain information.
Of course, you can add judgment and processing.
Option explicit
Dim objswbemservices as swbemservices
Dim objswbemobjectset as swbemobjectset
Dim objswbemobject as swbemobject
Private type netcard
Name as string
Ipadress as string
Ipsubnets as string
Ipgateway as string
Dnsstring0 as string
Dnsstring1 as string
Macadress as string
End type
Dim mtnetcard () as netcard
Private sub commandementclick ()
Dim I as long
For I = lbound (mtnetcard) to ubound (mtnetcard)-1
Text1 = text1 & "Nic:" & mtnetcard (I). Name & vbnewline
Text1 = text1 & "IP Address:" & mtnetcard (I). ipadress & vbnewline
Text1 = text1 & "subnet mask:" & mtnetcard (I). ipsubnets & vbnewline
Text1 = text1 & "Gateway:" & mtnetcard (I). ipgateway & vbnewline
Text1 = text1 & "dns1:" & mtnetcard (I). dnsstring0 & vbnewline
Text1 = text1 & "dns2:" & mtnetcard (I). dnsstring1 & vbnewline
Text1 = text1 & "Mac:" & mtnetcard (I). macadress & vbnewline
Next
Erase mtnetcard
End sub
Private sub form_load ()
Redim mtnetcard (0) as netcard
Set objswbemservices = GetObject ("winmgmts :")
Set objswbemobjectset = objswbemservices. execquery ("select * From win32_networkadapterconfiguration where ipenabled = true ")
For each objswbemobject in objswbemobjectset
On Error resume next
Mtnetcard (ubound (mtnetcard). Name = objswbemobject. description' Add a NIC with the TCP/IP protocol installed on the local machine
Mtnetcard (ubound (mtnetcard). ipadress = objswbemobject. IPaddress (0)
Mtnetcard (ubound (mtnetcard). ipsubnets = objswbemobject. ipsubnet (0)
Mtnetcard (ubound (mtnetcard). ipgateway = objswbemobject. defaultipgateway (0)
Mtnetcard (ubound (mtnetcard). dnsstring0 = objswbemobject. dnsserversearchorder (0)
Mtnetcard (ubound (mtnetcard). dnsstring1 = objswbemobject. dnsserversearchorder (1)
Mtnetcard (ubound (mtnetcard). macadress = objswbemobject. macaddress (0)
Redim preserve mtnetcard (ubound (mtnetcard) + 1) as netcard
Next
End sub