IpConfig plugin: Difference between revisions
Jpderuiter (talk | contribs) (Created page with '{{PageAuthor|jpderuiter}} == Links == <attach>IpConfig.zip</attach> [http://forums.winamp.com/showthread.php?s=&threadid=265680 IpConfig plugin thread on NSIS Discussion forum]...') |
Jpderuiter (talk | contribs) |
||
(6 intermediate revisions by the same user not shown) | |||
Line 4: | Line 4: | ||
<attach>IpConfig.zip</attach> | <attach>IpConfig.zip</attach> | ||
[http://forums.winamp.com/showthread.php?s=&threadid= | [http://forums.winamp.com/showthread.php?s=&threadid=307666 IpConfig plugin thread on NSIS Discussion forum] | ||
== Description == | == Description == | ||
Line 13: | Line 13: | ||
== Functions == | == Functions == | ||
: All functions returns 2 values: | |||
: - "ok" or "error" | |||
: - The requested value if "ok", an error message if "error" | |||
=== GetHostName === | === GetHostName === | ||
Line 90: | Line 94: | ||
IpConfig::GetEnabledNetworkAdaptersIDsCB CallbackAddress | IpConfig::GetEnabledNetworkAdaptersIDsCB CallbackAddress | ||
: Finds the ID's from all installed Networkadapters which are enabled. | : Finds the ID's from all installed Networkadapters which are enabled. | ||
: These are the active Network | : These are the active Network adapters. | ||
; Parameters | ; Parameters | ||
: CallbackAddress: For each ID found the function on this address is called after the ID is pushed to the stack. | : CallbackAddress: For each ID found the function on this address is called after the ID is pushed to the stack. | ||
Line 101: | Line 105: | ||
IpConfig::GetEnabledNetworkAdaptersIDs | IpConfig::GetEnabledNetworkAdaptersIDs | ||
: Finds the ID's from all installed Networkadapters which are enabled. | : Finds the ID's from all installed Networkadapters which are enabled. | ||
: These are the active Network | : These are the active Network adapters. | ||
; Return value | ; Return value | ||
: All found ID's in a space seperated string. | : All found ID's in a space seperated string. | ||
Line 356: | Line 360: | ||
<highlight-nsis>!Macro ShowResult ItemString | <highlight-nsis>!Macro ShowResult ItemString | ||
Pop $0 | |||
Pop $1 | Pop $1 | ||
${if} $0 == "ok" | ${if} $0 == "ok" | ||
Line 366: | Line 370: | ||
!Macro ShowMultiResult ItemString | !Macro ShowMultiResult ItemString | ||
Pop $0 | |||
Pop $1 | Pop $1 | ||
${if} $0 != "ok" | ${if} $0 != "ok" | ||
Line 376: | Line 380: | ||
DetailPrint "Windows IP-configuration" | DetailPrint "Windows IP-configuration" | ||
DetailPrint "" | DetailPrint "" | ||
IpConfig::GetHostName | |||
!InsertMacro ShowResult " Host Name.......................:" | |||
IpConfig::GetPrimaryDNSSuffix | |||
!InsertMacro ShowResult " Primary DNS Suffix..............:" | !InsertMacro ShowResult " Primary DNS Suffix..............:" | ||
IpConfig::GetNodeType | |||
!InsertMacro ShowResult " Node Type.......................:" | !InsertMacro ShowResult " Node Type.......................:" | ||
IpConfig::IsIPRoutingEnabled | |||
!InsertMacro ShowResult " IP Routing Enabled..............:" | !InsertMacro ShowResult " IP Routing Enabled..............:" | ||
IpConfig::IsWINSProxyEnabled | IpConfig::IsWINSProxyEnabled | ||
Line 395: | Line 399: | ||
Function EnabledAdaptersCallback | Function EnabledAdaptersCallback | ||
Pop $3 | |||
IpConfig::GetNetworkAdapterType $3 | |||
Pop $4 | Pop $4 | ||
Pop $5 | Pop $5 | ||
IpConfig::GetNetworkAdapterConnectionID $3 | |||
Pop $4 | Pop $4 | ||
Pop $6 | Pop $6 | ||
DetailPrint "$5 adapter $6" | DetailPrint "$5 adapter $6" | ||
IpConfig::GetNetworkAdapterConnectionSpecificDNSSuffix $3 | |||
!InsertMacro ShowResult " Connection-specific DNS Suffix..:" | !InsertMacro ShowResult " Connection-specific DNS Suffix..:" | ||
IpConfig::GetNetworkAdapterDescription $3 | |||
!InsertMacro ShowResult " Description.....................:" | !InsertMacro ShowResult " Description.....................:" | ||
IpConfig::GetNetworkAdapterMACAddress $3 | |||
!InsertMacro ShowResult " Physical Address................:" | !InsertMacro ShowResult " Physical Address................:" | ||
IpConfig::IsNetworkAdapterDHCPEnabled $3 | |||
!InsertMacro ShowResult " DHCP Enabled....................:" | !InsertMacro ShowResult " DHCP Enabled....................:" | ||
StrCpy $6 $1 | StrCpy $6 $1 | ||
IpConfig::IsNetworkAdapterAutoSense $3 | |||
!InsertMacro ShowResult " Autoconfiguration Enabled.......:" | !InsertMacro ShowResult " Autoconfiguration Enabled.......:" | ||
StrCpy $R0 0 | StrCpy $R0 0 | ||
Line 434: | Line 438: | ||
IpConfig::GetNetworkAdapterDNSServersCB $3 $4 | IpConfig::GetNetworkAdapterDNSServersCB $3 $4 | ||
!InsertMacro ShowMultiResult " GetNetworkAdapterDNSServers:" | !InsertMacro ShowMultiResult " GetNetworkAdapterDNSServers:" | ||
IpConfig::GetNetworkAdapterPrimaryWINSServer $3 | |||
!InsertMacro ShowResult " Primary WINS Server.............:" | !InsertMacro ShowResult " Primary WINS Server.............:" | ||
IpConfig::GetNetworkAdapterSecondaryWINSServer $3 | |||
!InsertMacro ShowResult " Secondary WINS Server...........:" | !InsertMacro ShowResult " Secondary WINS Server...........:" | ||
${If} $6 == "Yes" | ${If} $6 == "Yes" | ||
Line 448: | Line 452: | ||
Function IPAddressesCallback | Function IPAddressesCallback | ||
Pop $5 | |||
${if} $R0 == 0 | ${if} $R0 == 0 | ||
DetailPrint " IP Address......................: $5" | DetailPrint " IP Address......................: $5" | ||
Line 458: | Line 462: | ||
Function IPSubNetsCallback | Function IPSubNetsCallback | ||
Pop $5 | |||
${if} $R0 == 0 | ${if} $R0 == 0 | ||
DetailPrint " Subnet Mask.....................: $5" | DetailPrint " Subnet Mask.....................: $5" | ||
Line 468: | Line 472: | ||
Function DefaultIPGatewaysCallback | Function DefaultIPGatewaysCallback | ||
Pop $5 | |||
${if} $R0 == 0 | ${if} $R0 == 0 | ||
DetailPrint " Default Gateway.................: $5" | DetailPrint " Default Gateway.................: $5" | ||
Line 478: | Line 482: | ||
Function DNSServersCallback | Function DNSServersCallback | ||
Pop $5 | |||
${if} $R0 == 0 | ${if} $R0 == 0 | ||
DetailPrint " DNS Servers.....................: $5" | DetailPrint " DNS Servers.....................: $5" | ||
Line 487: | Line 491: | ||
FunctionEnd</highlight-nsis> | FunctionEnd</highlight-nsis> | ||
=== nsDialogs example without | === nsDialogs example without using callbacks === | ||
: This example creates a custom nsDialogs Page with a droplist containing all enabled network adapters. | : This example creates a custom nsDialogs Page with a droplist containing all enabled network adapters. | ||
Line 565: | Line 569: | ||
${NSD_SetText} $IPAddress "$3" | ${NSD_SetText} $IPAddress "$3" | ||
FunctionEnd</highlight-nsis> | FunctionEnd</highlight-nsis> | ||
=== Find MAC address for a given IP address === | |||
<highlight-nsis> IpConfig::GetNetworkAdapterIDFromIPAddress "192.168.1.33" | |||
Pop $0 | |||
Pop $1 | |||
StrCmp $0 "ok" 0 error | |||
IpConfig::GetNetworkAdapterMACAddress $1 | |||
Pop $0 | |||
Pop $2 | |||
DetailPrint "MACAddress from adapter #$1: $2" | |||
Goto end | |||
error: | |||
DetailPrint "$1" | |||
end: | |||
</highlight-nsis> | |||
== Version History == | == Version History == |
Latest revision as of 19:33, 24 June 2009
Author: jpderuiter (talk, contrib) |
Links
IpConfig.zip (141 KB)
IpConfig plugin thread on NSIS Discussion forum
Description
Version: 0.1.
With the IpConfig plugin you can query all kinds of network info, mainly the same info you get with the shell command ipconfig /all. Both an ANSI as well as a Unicode plugin DLL is available.
Functions
- All functions returns 2 values:
- - "ok" or "error"
- - The requested value if "ok", an error message if "error"
GetHostName
IpConfig::GetHostName
- Gets the hostname of the computer.
- Return value
- The hostname of the computer.
GetPrimaryDNSSuffix
IpConfig::GetPrimaryDNSSuffix
- Gets the Primary DNS Suffix of the computer.
- Return value
- The Primary DNS Suffix of the computer.
GetNodeType
IpConfig::GetNodeType
- Gets the Node Type of the computer.
- Possible return values
- - Broadcast (B-node)
- - Peer-Peer (P-node)
- - Mixed (M-node)
- - Hybrid (H-node)
- - Unknown
IsIPRoutingEnabled
IpConfig::IsIPRoutingEnabled
- Checks if IP Routing is enabled on the computer.
- Possible return values
- - Yes
- - No
IsWINSProxyEnabled
IpConfig::IsWINSProxyEnabled
- Checks if WINS Proxy is enabled on the computer.
- Possible return values
- - Yes
- - No
More info on MSDN (DNSEnabledForWINSResolution)
GetDNSSuffixSearchList
IpConfig::GetDNSSuffixSearchList
- Gets the DNS Suffix SearchList of the computer.
- Return value
- The DNS Suffix SearchList of the computer.
GetAllNetworkAdaptersIDsCB
IpConfig::GetAllNetworkAdaptersIDsCB CallbackAddress
- Finds the ID's from all installed Networkadapters.
- The use of this function is not recommended, use GetEnabledNetworkAdaptersIDsCB instead.
- Parameters
- CallbackAddress: For each ID found the function on this address is called after the ID is pushed to the stack.
- Return value
- The number of Network adapters found.
GetAllNetworkAdaptersIDs
IpConfig::GetAllNetworkAdaptersIDs
- Finds the ID's from all installed Networkadapters.
- The use of this function is not recommended, use GetEnabledNetworkAdaptersIDs instead.
- Return value
- All found ID's in a space seperated string.
GetEnabledNetworkAdaptersIDsCB
IpConfig::GetEnabledNetworkAdaptersIDsCB CallbackAddress
- Finds the ID's from all installed Networkadapters which are enabled.
- These are the active Network adapters.
- Parameters
- CallbackAddress: For each ID found the function on this address is called after the ID is pushed to the stack.
- Return value
- The number of Network adapters found.
GetEnabledNetworkAdaptersIDs
IpConfig::GetEnabledNetworkAdaptersIDs
- Finds the ID's from all installed Networkadapters which are enabled.
- These are the active Network adapters.
- Return value
- All found ID's in a space seperated string.
GetNetworkAdapterIDFromDescription
IpConfig::GetNetworkAdapterIDFromDescription Description
- Gets the ID from the NetworkAdapter with the given Description.
- Parameters
- Description: The description to look for.
- Return value
- The ID from the NetworkAdapter with the given Description.
More info on MSDN (Description)
GetNetworkAdapterIDFromMACAddress
IpConfig::GetNetworkAdapterIDFromMACAddress MACAddress
- Gets the ID from the NetworkAdapter with the given MAC Address.
- Parameters
- MACAddress: The MAC Address to look for.
- Return value
- The ID from the NetworkAdapter with the given MAC Address.
More info on MSDN (MACAddress)
GetNetworkAdapterIDFromIPAddress
IpConfig::GetNetworkAdapterIDFromIPAddress IPAddress
- Gets the ID from the NetworkAdapter with the given IP Address.
- NOTE: only the first hit will be returned.
- Parameters
- IPAddress: The IP Address to look for.
- Return value
- The ID from the NetworkAdapter with the given IP Address.
GetNetworkAdapterType
IpConfig::GetNetworkAdapterType NetworkAdapterID
- Gets the Type of the given Networkadapter.
- Parameters
- NetworkAdapterID
- Possible return values (See link below for a complete list)
- - Ethernet 802.3
- - Token Ring 802.5
- - Wide Area Network (WAN)
- - Wireless
More info on MSDN (AdapterType)
GetNetworkAdapterConnectionID
IpConfig::GetNetworkAdapterConnectionID NetworkAdapterID
- Gets the Connection ID of the given Networkadapter.
- This is the Name of the network connection as it appears in the Network Connections Control Panel program.
- Parameters
- NetworkAdapterID
- Return value
- The Connection ID of the given Networkadapter.
More info on MSDN (NetConnectionID)
GetNetworkAdapterConnectionSpecificDNSSuffix
IpConfig::GetNetworkAdapterConnectionSpecificDNSSuffix NetworkAdapterID
- Gets the DNS Suffix of the given Networkadapter.
- Parameters
- NetworkAdapterID
- Return value
- The DNS Suffix of the given Networkadapter.
GetNetworkAdapterDescription
IpConfig::GetNetworkAdapterDescription NetworkAdapterID
- Gets the Description of the given Networkadapter.
- Parameters
- NetworkAdapterID
- Return value
- The Description of the given Networkadapter.
More info on MSDN (Description)
GetNetworkAdapterMACAddress
IpConfig::GetNetworkAdapterMACAddress NetworkAdapterID
- Gets the MAC Address of the given Networkadapter.
- Parameters
- NetworkAdapterID
- Return value
- The MAC Address of the given Networkadapter.
More info on MSDN (MACAddress)
IsNetworkAdapterDHCPEnabled
IpConfig::IsNetworkAdapterDHCPEnabled NetworkAdapterID
- Checks if DHCP is enabled for the given Networkadapter.
- Parameters
- NetworkAdapterID
- Possible return values
- - Yes
- - No
More info on MSDN (DHCPEnabled)
IsNetworkAdapterAutoSense
IpConfig::IsNetworkAdapterAutoSense NetworkAdapterID
- Checks if the given Networkadapter can automatically determine the speed of the attached network media.
- Parameters
- NetworkAdapterID
- Possible return values
- - Yes
- - No
GetNetworkAdapterIPAddressesCB
IpConfig::GetNetworkAdapterIPAddressesCB NetworkAdapterID CallbackAddress
- Finds the IP addresses for the given Networkadapter.
- Parameters
- NetworkAdapterID
- CallbackAddress: For each IP address found the function on this address is called after the IP address is pushed to the stack.
- Return value
- The number of IP addresses found.
GetNetworkAdapterIPAddresses
IpConfig::GetNetworkAdapterIPAddresses NetworkAdapterID
- Finds the IP addresses for the given Networkadapter.
- Parameters
- NetworkAdapterID
- Return value
- All found IP addresses in a space seperated string.
GetNetworkAdapterIPSubNetsCB
IpConfig::GetNetworkAdapterIPSubNetsCB NetworkAdapterID CallbackAddress
- Finds the subnet masks associated with the given Networkadapter.
- Parameters
- NetworkAdapterID
- CallbackAddress: For each subnet mask found the function on this address is called after the subnet mask is pushed to the stack.
- Return value
- The number of subnet masks found.
GetNetworkAdapterIPSubNets
IpConfig::GetNetworkAdapterIPSubNets NetworkAdapterID
- Finds the subnet masks associated with the given Networkadapter.
- Parameters
- NetworkAdapterID
- Return value
- All found subnet masks in a space seperated string.
GetNetworkAdapterDefaultIPGatewaysCB
IpConfig::GetNetworkAdapterDefaultIPGatewaysCB NetworkAdapterID CallbackAddress
- Finds the IP addresses of default gateways for the given Networkadapter.
- Parameters
- NetworkAdapterID
- CallbackAddress: For each IP address found the function on this address is called after the IP address is pushed to the stack.
- Return value
- The number of IP addresses found.
More info on MSDN (DefaultIPGateway)
GetNetworkAdapterDefaultIPGateways
IpConfig::GetNetworkAdapterDefaultIPGateways NetworkAdapterID
- Finds the IP addresses of default gateways for the given Networkadapter.
- Parameters
- NetworkAdapterID
- Return value
- All found IP addresses in a space seperated string.
More info on MSDN (DefaultIPGateway)
GetNetworkAdapterDHCPServer
IpConfig::GetNetworkAdapterDHCPServer NetworkAdapterID
- Gets the IP address of the DHCP server of the given Networkadapter.
- Parameters
- NetworkAdapterID
- Return value
- The IP address of the DHCP server of the given Networkadapter.
More info on MSDN (DHCPServer)
GetNetworkAdapterDNSServersCB
IpConfig::GetNetworkAdapterDNSServersCB NetworkAdapterID CallbackAddress
- Finds the server IP addresses to be used in querying for DNS servers on the given Networkadapter.
- Parameters
- NetworkAdapterID
- CallbackAddress: For each IP address found the function on this address is called after the IP address is pushed to the stack.
- Return value
- The number of IP addresses found.
More info on MSDN (DNSServerSearchOrder)
GetNetworkAdapterDNSServers
IpConfig::GetNetworkAdapterDNSServers NetworkAdapterID
- Finds the server IP addresses to be used in querying for DNS servers on the given Networkadapter.
- Parameters
- NetworkAdapterID
- Return value
- All found IP addresses in a space seperated string.
More info on MSDN (DNSServerSearchOrder)
GetNetworkAdapterPrimaryWINSServer
IpConfig::GetNetworkAdapterPrimaryWINSServer NetworkAdapterID
- Gets the IP address for the primary WINS server of the given Networkadapter.
- Parameters
- NetworkAdapterID
- Return value
- The IP address of the primary WINS server of the given Networkadapter.
More info on MSDN (WINSPrimaryServer)
GetNetworkAdapterSecondaryWINSServer
IpConfig::GetNetworkAdapterSecondaryWINSServer NetworkAdapterID
- Gets the IP address for the secondary WINS server of the given Networkadapter.
- Parameters
- NetworkAdapterID
- Return value
- The IP address of the secondary WINS server of the given Networkadapter.
More info on MSDN (WINSSecondaryServer)
GetNetworkAdapterDHCPLeaseObtained
IpConfig::GetNetworkAdapterDHCPLeaseObtained NetworkAdapterID
- Gets the date and time when DHCP was obtained for the given Networkadapter.
- Parameters
- NetworkAdapterID
- Return value
- The date and time when DHCP will expire for the given Networkadapter.
- Format: "{Day}.{Month}.{Year} {Hour}:{Minute}:{Second}" (Compatible with the Time plugin).
More info on MSDN (DHCPLeaseExpires)
GetNetworkAdapterDHCPLeaseExpires
IpConfig::GetNetworkAdapterDHCPLeaseExpires NetworkAdapterID
- Gets the date and time when DHCP will expire for the given Networkadapter.
- Parameters
- NetworkAdapterID
- Return value
- The date and time when DHCP will expire for the given Networkadapter.
- Format: "{Day}.{Month}.{Year} {Hour}:{Minute}:{Second}" (Compatible with the Time plugin).
More info on MSDN (DHCPLeaseExpires)
Examples
IpConfig /all (using callbacks)
- This example imitates the ipconfig /all command.
!Macro ShowResult ItemString Pop $0 Pop $1 ${if} $0 == "ok" DetailPrint "${ItemString} $1" ${Else} DetailPrint "${ItemString} Error: $1" ${EndIf} !MacroEnd !Macro ShowMultiResult ItemString Pop $0 Pop $1 ${if} $0 != "ok" DetailPrint "${ItemString} Error: $1" ${EndIf} !MacroEnd Section DetailPrint "Windows IP-configuration" DetailPrint "" IpConfig::GetHostName !InsertMacro ShowResult " Host Name.......................:" IpConfig::GetPrimaryDNSSuffix !InsertMacro ShowResult " Primary DNS Suffix..............:" IpConfig::GetNodeType !InsertMacro ShowResult " Node Type.......................:" IpConfig::IsIPRoutingEnabled !InsertMacro ShowResult " IP Routing Enabled..............:" IpConfig::IsWINSProxyEnabled !InsertMacro ShowResult " WINS Proxy Enabled..............:" IpConfig::GetDNSSuffixSearchList !InsertMacro ShowResult " DNS Suffix Search List..........:" DetailPrint "" GetFunctionAddress $2 EnabledAdaptersCallback IpConfig::GetEnabledNetworkAdaptersIDsCB $2 !InsertMacro ShowMultiResult " GetEnabledNetworkAdaptersIDs:" SectionEnd Function EnabledAdaptersCallback Pop $3 IpConfig::GetNetworkAdapterType $3 Pop $4 Pop $5 IpConfig::GetNetworkAdapterConnectionID $3 Pop $4 Pop $6 DetailPrint "$5 adapter $6" IpConfig::GetNetworkAdapterConnectionSpecificDNSSuffix $3 !InsertMacro ShowResult " Connection-specific DNS Suffix..:" IpConfig::GetNetworkAdapterDescription $3 !InsertMacro ShowResult " Description.....................:" IpConfig::GetNetworkAdapterMACAddress $3 !InsertMacro ShowResult " Physical Address................:" IpConfig::IsNetworkAdapterDHCPEnabled $3 !InsertMacro ShowResult " DHCP Enabled....................:" StrCpy $6 $1 IpConfig::IsNetworkAdapterAutoSense $3 !InsertMacro ShowResult " Autoconfiguration Enabled.......:" StrCpy $R0 0 GetFunctionAddress $4 IPAddressesCallback IpConfig::GetNetworkAdapterIPAddressesCB $3 $4 !InsertMacro ShowMultiResult " GetEnabledNetworkAdaptersIPAddresses:" StrCpy $R0 0 GetFunctionAddress $4 IPSubNetsCallback IpConfig::GetNetworkAdapterIPSubNetsCB $3 $4 !InsertMacro ShowMultiResult " GetNetworkAdapterIPSubNets:" StrCpy $R0 0 GetFunctionAddress $4 DefaultIPGatewaysCallback IpConfig::GetNetworkAdapterDefaultIPGatewaysCB $3 $4 !InsertMacro ShowMultiResult " GetNetworkAdapterDefaultIPGateways:" ${If} $6 == "Yes" IpConfig::GetNetworkAdapterDHCPServer $3 !InsertMacro ShowResult " DHCP Server.....................:" ${EndIf} StrCpy $R0 0 GetFunctionAddress $4 DNSServersCallback IpConfig::GetNetworkAdapterDNSServersCB $3 $4 !InsertMacro ShowMultiResult " GetNetworkAdapterDNSServers:" IpConfig::GetNetworkAdapterPrimaryWINSServer $3 !InsertMacro ShowResult " Primary WINS Server.............:" IpConfig::GetNetworkAdapterSecondaryWINSServer $3 !InsertMacro ShowResult " Secondary WINS Server...........:" ${If} $6 == "Yes" IpConfig::GetNetworkAdapterDHCPLeaseObtained $3 !InsertMacro ShowResult " Lease Obtained..................:" IpConfig::GetNetworkAdapterDHCPLeaseExpires $3 !InsertMacro ShowResult " Lease Expires...................:" ${EndIf} DetailPrint "" FunctionEnd Function IPAddressesCallback Pop $5 ${if} $R0 == 0 DetailPrint " IP Address......................: $5" IntOp $R0 $R0 + 1 ${Else} DetailPrint " $5" ${EndIf} FunctionEnd Function IPSubNetsCallback Pop $5 ${if} $R0 == 0 DetailPrint " Subnet Mask.....................: $5" IntOp $R0 $R0 + 1 ${Else} DetailPrint " $5" ${EndIf} FunctionEnd Function DefaultIPGatewaysCallback Pop $5 ${if} $R0 == 0 DetailPrint " Default Gateway.................: $5" IntOp $R0 $R0 + 1 ${Else} DetailPrint " $5" ${EndIf} FunctionEnd Function DNSServersCallback Pop $5 ${if} $R0 == 0 DetailPrint " DNS Servers.....................: $5" IntOp $R0 $R0 + 1 ${Else} DetailPrint " $5" ${EndIf} FunctionEnd
nsDialogs example without using callbacks
- This example creates a custom nsDialogs Page with a droplist containing all enabled network adapters.
- Two textboxes contains the MAC address and all IP adresses from the selected network adapter.
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 ; Get next AdapterID from the Id string IpConfig::GetNetworkAdapterDescription $R0 Pop $1 Pop $1 ${If} $2 == 0 StrCpy $2 $1 ; remember the first entry to show as first 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
Find MAC address for a given IP address
IpConfig::GetNetworkAdapterIDFromIPAddress "192.168.1.33" Pop $0 Pop $1 StrCmp $0 "ok" 0 error IpConfig::GetNetworkAdapterMACAddress $1 Pop $0 Pop $2 DetailPrint "MACAddress from adapter #$1: $2" Goto end error: DetailPrint "$1" end:
Version History
[version 0.1: 2009-07-24]
- Initial version.
JP de Ruiter