Hostname() returns string in lowercase

Just starting out? Need help? Post your questions and find answers here.
User avatar
IceSoft
Addict
Addict
Posts: 1682
Joined: Thu Jun 24, 2004 8:51 am
Location: Germany

Hostname() returns string in lowercase

Post 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") 
Last edited by IceSoft on Wed Jul 11, 2007 11:41 am, edited 1 time in total.
Belive! C++ version of Puzzle of Mystralia
<Wrapper>4PB, PB<game>, =QONK=, PetriDish, Movie2Image, PictureManager,...
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: [B4.10b2] Hostname() returns string in lowercase...

Post 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).
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
User avatar
IceSoft
Addict
Addict
Posts: 1682
Joined: Thu Jun 24, 2004 8:51 am
Location: Germany

Re: [B4.10b2] Hostname() returns string in lowercase...

Post 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.
Belive! C++ version of Puzzle of Mystralia
<Wrapper>4PB, PB<game>, =QONK=, PetriDish, Movie2Image, PictureManager,...
ABBKlaus
Addict
Addict
Posts: 1143
Joined: Sat Apr 10, 2004 1:20 pm
Location: Germany

Post 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$ :wink:

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
freak
PureBasic Team
PureBasic Team
Posts: 5940
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Post by freak »

Yes, the NetBIOS name can be different from the hostname. There is no bug here.
quidquid Latine dictum sit altum videtur
Post Reply