Pb With API and GetComputerName

BlitzMax Forums/BlitzMax Programming/Pb With API and GetComputerName

Extern "win32"
	Function GetComputerNameA(lpbuffer:Byte Ptr,nSize:Int Ptr)
EndExtern

Local Size = 32								' maximum length of cstring
Local Buffer:Byte Ptr = MemAlloc(Size)		' allocate memory to hold cstring
GetComputerNameA(buffer,Varptr(size))		' ask for name
Local name$ = String.FromCString(buffer)	' convert cstring to string
MemFree buffer 								' release cstring

Print name$
Print "computer name contains "+size+" characters"

Hope that helps :)