;
; Get HostName (like the console command 'hostname')
;
; ------------------------
; STRUCTURE WKSTA_INFO_100
;
; The WKSTA_INFO_100 Structure contains information about a workstation environment,
; including platform-specific information, the names of the domain And the local
; computer, And information concerning the operating system.
;
; wki100_platform_id
; Specifies the information level To use To retrieve platform-specific information.
; This member can be one of the following values, defined in the lmcons.h file:
; PLATFORM_ID_DOS, PLATFORM_ID_OS2, PLATFORM_ID_NT, PLATFORM_ID_OSF, Or PLATFORM_ID_VMS.
; wki100_computername
; Pointer To a Unicode string specifying the name of the local computer.
; wki100_langroup
; Pointer To a Unicode string specifying the name of the domain To which the computer
; belongs.
; wki100_ver_major
; Specifies the major version number of the operating system running on the computer.
; wki100_ver_minor
; Specifies the minor version number of the operating system running on the computer.
;
Structure WKSTA_INFO_100
wki100_platform_id.l
wki100_computername.l
wki100_langroup.l
wki100_ver_major.l
wki100_ver_minor.l
EndStructure
; ------------------------
Procedure.s GetHostName()
WorkstationEnv.WKSTA_INFO_100
WorkstationConfigElements.l
WKSTASize = SizeOf(WKSTA_INFO_100)
; The NetWkstaGetInfo function returns information about the configuration elements for a workstation.
Result = NetWkstaGetInfo_(0, 100, @WorkstationConfigElements)
If Result = 0
CMResult = CopyMemory(WorkstationConfigElements, @WorkstationEnv, WKSTASize)
Buffer.s = Space(512)
; The WideCharToMultiByte function maps a wide-character string to a new character string.
; CP_ACP = ANSI code page
Result = WideCharToMultiByte_(#CP_ACP ,0,WorkstationEnv\wki100_computername,-1,@Buffer.s,512,0,0)
ProcedureReturn Trim(Buffer)
Else
ProcedureReturn "Unknown"
EndIf
EndProcedure
; ------------------------
HostName.s = GetHostName()
MessageRequester("HostName",HostName,0)