Code: Select all
ImportC ""
CFRelease(CFTypeRef.L)
CFStringGetCString(CFStringRef.L, *Buffer, BufferSize, Encoding.L)
CSCopyMachineName()
CSCopyUserName(UseShortName.L)
EndImport
Procedure.S AddNameToInfo(NameRef.L, Description.S)
Shared Info.S
Protected Name.S = Space(100)
If NameRef
If CFStringGetCString(NameRef, @Name, Len(Name), 0)
Info + #CR$ + Description + " = " + Name
EndIf
CFRelease(NameRef)
EndIf
EndProcedure
Define Info.S
AddNameToInfo(CSCopyMachineName(), "Machine name")
AddNameToInfo(CSCopyUserName(#True), "User's short name")
AddNameToInfo(CSCopyUserName(#False), "User's long name")
MessageRequester("System Info", Info)
function Hostname() (and therefore even cross-platform):
Code: Select all
InitNetwork()
Debug Hostname()
name of my DSL router:
whereas my first API code example displays the correct nameDebug Hostname() wrote:shardiks-imac.fritz.box
Update: freak clarified that the host name is not necessarily identical to the computer name:Shardiks-iMac
http://www.purebasic.fr/english/viewtop ... 52&start=1