最新消息:

IpConfig是NSIS获取网卡MAC地址IP地址的网络插件

nsis 永恒心锁 2533浏览 0评论
/*
IpConfig是NSIS获取网卡MAC地址IP地址的网络插件
使用IpConfig插件你可以查询许多网络信息,大部分的信息如同你使用命令行ipconfig /all类似.
IpConfig::GetHostName可以获得主机名如:admin
IpConfig::GetNetworkAdapterDescription NetworkAdapterID:通过网络适配器ID获得描述名称.
IpConfig::GetNetworkAdapterMACAddress NetworkAdapterID:通过网络适配器ID获得MAC地址.
IpConfig::GetNetworkAdapterIPAddressesCB NetworkAdapterID CallbackAddress:通过网络适配器ID获得IP地址,并且可以自定义回调函数处理相关消息.
*/
!AddPluginDir "../../Plugins"
!include MUI2.nsh
!include LogicLib.nsh
!include WordFunc.nsh
Name `Test IpConfig plugin without callbacks`
OutFile `IpConfig.exe`
Page custom TestIpConfigInit
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_LANGUAGE English
Var DropList
var Dialog
var MACAddress
var IPAddress
Section
SectionEnd
Function TestIpConfigInit
nsDialogs::Create 1018
Pop $Dialog
${NSD_CreateDropList} 20 20 90% 48u ""
Pop $DropList
GetFunctionAddress $0 DropList_Changed
nsDialogs::OnChange $DropList $0
IpConfig::GetEnabledNetworkAdaptersIDs
Pop $0
Pop $0
StrCpy $2 0
StrCpy $4 0
ClearErrors
${Do}
StrCpy $3 $0
${WordFind} "$0" " " "+1{" $R0
IpConfig::GetNetworkAdapterDescription $R0
Pop $1
Pop $1
${If} $2 == 0
StrCpy $2 $1
StrCpy $4 $R0
${EndIf}
${NSD_CB_AddString} $DropList $1
${WordReplace} "$0" "$R0 " "" "E+1" $0
${LoopUntil} ${Errors}
ClearErrors
${NSD_CB_SelectString} $DropList $2
${NSD_CreateLabel} 20 62 80 12u "MAC Address"
Pop $1
IpConfig::GetNetworkAdapterMACAddress $4
Pop $1
Pop $1
${NSD_CreateText} 120 60 180 12u "$1"
Pop $MACAddress
${NSD_CreateLabel} 20 82 80 12u "IP Address"
Pop $1
IpConfig::GetNetworkAdapterIPAddresses $4
Pop $1
Pop $1
${NSD_CreateText} 120 80 180 12u "$1"
Pop $IPAddress
nsDialogs::Show
FunctionEnd
Function DropList_Changed
${NSD_GetText} $DropList $0
IpConfig::GetNetworkAdapterIDFromDescription $0
Pop $1
Pop $1
IpConfig::GetNetworkAdapterMACAddress $1
Pop $2
Pop $3
${NSD_SetText} $MACAddress "$3"
IpConfig::GetNetworkAdapterIPAddresses $1
Pop $2
Pop $3
${NSD_SetText} $IPAddress "$3"
FunctionEnd
永恒心锁,版权所有丨如未注明,均为转载丨本网站采用BY-NC-SA协议进行授权

转载请注明:永恒心锁-分享互联网 » IpConfig是NSIS获取网卡MAC地址IP地址的网络插件

您必须 登录 才能发表评论!