vb實現IP設定

2021-04-18 09:38:44 字數 1609 閱讀 1693

看到有人說我的共享有毒,讓我很是詫異。我用的系統是卡巴斯基7,我是沒有查出毒來,如果你查出來了最好說下是什麼病毒,我好研究下到底是怎麼回事兒)

介面如下:

其實利用vb修改ip位址是比較容易的。我利用的就是wmi方式。先是找出當前系統的所有網絡卡資訊,下面給出的是找出所有網絡卡mac位址

的例程:

function getmacaddress()

strcomputer = "."

set objwmiservicegl = getobject("winmgmts://" & strcomputer & "/root/cimv2")

set colnetadaptersgl = objwmiservicegl.execquery("select * from win32_networkadapterconfiguration where (ipenabled=true)")

for each objnetadaptergl in colnetadaptersgl         

getmacaddress=getmacaddress & objnetadaptergl.macaddress & vbcrlf    

next

end function

然後根據所找到的各個網絡卡的進行資訊(ip,dns等)更改:

function modifyip()

strcomputer = "."

set objwmiservice = getobject("winmgmts://" & strcomputer & "/root/cimv2")

set objnetadapter = objswbemservices.execquery("select * from win32_networkadapterconfiguration where description='" & combo1.text & "'")        

stripaddress = array(text1.text)        

strsubnetmask = array(text2.text)        

strgateway = array(text3.text)        

strgatewaymetric = array(1)        

strdns = array(text4.text, text5.text)                

errenable = objnetadapter.enablestatic(stripaddress, strsubnetmask)        

errgateways = objnetadapter.setgateways(strgateway, strgatewaymetric)        

errdns = objnetadapter.setdnsserversearchorder(strdns)

end function 完

VB設定網絡卡的IP位址

option explicit dimobjswbemservices asswbemservices dimobjswbemobjectset asswbemobjectset dimobjswbemobject asswbemobject text1 0 為ip位址 text1 1 為子網掩碼 ...

設定ip位址,vm設定mac與ip

eth0為本地網絡卡 設定靜態ip vi etc sysconfig network scripts ifcfg eth0 dmesg grep eth0 命令進行檢視並更新 type ethernet uuid 95a6c75d c047 48d9 a534 51034f566725 也建議修改 ...

VB設定軟體開機啟動

如何設定軟體自啟動?呼叫一系列api函式 private declare function regclosekey lib advapi32.dll byval hkey as long as long const hkey local machine private declare functio...