Page 1 of 1
Hostname() returns string in lowercase
Posted: Wed Jul 11, 2007 7:31 am
by IceSoft
MAybe it should be a uppercase string like I get with the API and with the environment variable too.
Code: Select all
Debug "Get hostname with nativ PB function:"
InitNetwork()
Debug Hostname()
Debug "Get hostname with API:"
#MAX_COMPUTERNAME_LENGTH = 31
computername_length = #MAX_COMPUTERNAME_LENGTH + 1
computername$ = Space(computername_length)
GetComputerName_(@computername$, @computername_length)
Debug computername$
Debug "Get hostname with environment:"
Debug GetEnvironmentVariable("COMPUTERNAME")
Re: [B4.10b2] Hostname() returns string in lowercase...
Posted: Wed Jul 11, 2007 10:51 am
by PB
Does it matter? (And I'm not being rude, I'm being serious). I thought it would be
like filenames, where case doesn't matter? Or is this not the case (pun intended).
Re: [B4.10b2] Hostname() returns string in lowercase...
Posted: Wed Jul 11, 2007 11:03 am
by IceSoft
PB wrote:Does it matter? (And I'm not being rude, I'm being serious). I thought it would be
like filenames, where case doesn't matter? Or is this not the case (pun intended).
Maybe not. But it is different. That is the (minor) bug.
Posted: Wed Jul 11, 2007 11:09 am
by ABBKlaus
What did you expect ?
The GetComputerName_() API gets the Netbios-Name and differs from the function PB uses, so you have to ask M$
Code: Select all
;InitNetwork()
;Debug Hostname()
;
;Hostname() function as API
WS2_32=OpenLibrary(#PB_Any,"Ws2_32.dll")
If WS2_32
wsastartup=CallFunction(WS2_32,"WSAStartup",514,lpWSAData.WSADATA) ; Version = 2.2
Select wsastartup
Case #WSASYSNOTREADY
Debug "#WSASYSNOTREADY"
Case #WSAVERNOTSUPPORTED
Debug "#WSAVERNOTSUPPORTED"
Case #WSAEINPROGRESS
Debug "#WSAEINPROGRESS"
Case #WSAEPROCLIM
Debug "#WSAEPROCLIM"
Case #WSAEFAULT
Debug "#WSAEFAULT"
Case 0
Debug "WSAStartup success"
Default
Debug "?"
EndSelect
If wsastartup=0
*Buffer=AllocateMemory(256)
If CallFunction(WS2_32,"gethostname",*Buffer,256)=0
Debug PeekS(*Buffer,-1,#PB_Ascii)
EndIf
EndIf
EndIf
Posted: Wed Jul 11, 2007 11:19 am
by freak
Yes, the NetBIOS name can be different from the hostname. There is no bug here.