View Full Version : How to get FQDN using NSIS Script
nsisadmin
10th November 2010, 13:46
Currently we are using "Internet::GetLocalHostIP ${ip_addr}" to get the local host IP and using the IP for registering the application.
But to handle hosts with multiple NIC card, we are planing to use the FQDN(Fully Qualified Domain Name) instead of the ip address.
Is there any way to get the FQDN of the localhost using NSI script? Any other known workaround?
- Bhupen
nsisadmin
10th November 2010, 16:42
may be we can get the fqdn by appending domain name after hostname. how to get the hostname? any available plugin?
Zinthose
10th November 2010, 16:55
I believe you want to use the getnameinfo win32 api call for this.
http://msdn.microsoft.com/en-us/library/ms738532%28VS.85%29.aspx (http://msdn.microsoft.com/en-us/library/ms738532%28VS.85%29.aspx)
Zinthose
10th November 2010, 19:06
... Ignore the Other Zinthose he is a newb.. use this instead.!ifndef GetFQDN
!ifmacrondef _GetFQDN
!define GetFQDN "!insertmacro _GetFQDN"
!macro _GetFQDN _RetVar
!ifdef __UNINSTALL__
Call un.GetFQDN
!else
Call GetFQDN
!endif
!if ${_RetVar} != s
Pop ${_RetVar}
!endif
!macroend
!ifdef __UNINSTALL__
!define Uninst_ "un."
!else
!define Uninst_ ""
!endif
Function ${Uninst_}GetFQDN
!undef Uninst_
## This Function uses the GetNetworkParams Win32 API function.
## Additional details are available at:
## http://msdn.microsoft.com/en-us/library/aa365968%28VS.85%29.aspx
ClearErrors
Push $1
Push $0
Push $2
## Get the required buffer size
System::Call "*(&i4 0)i .r0"
System::Call 'Iphlpapi::GetNetworkParams(i 0, i r0)i.r1'
StrCmp $1 111 BufferOkay
SetErrors
StrCpy $1 ""
Goto CleanUp_End
BufferOkay:
## Allocate Buffer
System::Call '*$0(i .r1)'
System::Alloc $1
Pop $2
## Populate Buffer with Data
System::Call 'Iphlpapi::GetNetworkParams(i $2, *i $1)i.r1'
StrCmp $1 0 DataOkay
SetErrors
StrCpy $1 ""
Goto CleanUp
DataOkay:
## Success, lets build the FQDN from the data
System::Call '*$2(&t132 .r3,&t132 .r4)'
StrCpy $1 "$3.$4"
CleanUp:
System::Free $2
CleanUp_End:
System::Free $0
Pop $2
Pop $0
Exch $1
FunctionEnd
!endif
!endif
Section
${GetFQDN} $0
DetailPrint $0
SectionEnd
Zinthose
11th November 2010, 13:05
http://nsis.sourceforge.net/Fully_Qualified_Domain_Name
nsisadmin
15th November 2010, 04:34
Thanks Zinthose. The wiki was of great help.
I need to use few of the IpConfig plugin APIs(like GetHostName, GetPrimaryDNSSuffix, GetAllNetworkAdaptersIDs, GetEnabledNetworkAdaptersIDs, GetNetworkAdapterIPAddresses etc.). But looks like IpConfig plugin is not working properly(I am trying with windows XP).
Please help.
Zinthose
15th November 2010, 21:28
Looks like you already found the IPConfig Plugin Forum Topic (http://forums.winamp.com/showthread.php?s=&threadid=307666)
Listen To MSG he has the answer ;-)
The dll should be in NSIS\Plugins, not $INSTDIR\plugin.
Just to clarify that is the NSIS\Plugins dir were you have NSIS installed.
vBulletin® v3.8.6, Copyright ©2000-2013, Jelsoft Enterprises Ltd.