Answered my own question. Here is how to get username and machine/computername across all versions of Windows
[This message has been edited by Wayne Diamond (edited August 15, 2001).]
Code:
#COMPILE EXE #INCLUDE "win32api.inc" FUNCTION GetloggedOnUser() AS STRING DIM acUserName AS ASCIIZ * 100 DIM nUserName AS LONG nUserName = SIZEOF(acUserName) IF (GetUserName(acUserName, nUserName) = 0) THEN STDOUT "Failed to lookup user name, error code " + STR$(GetLastError) ELSE STDOUT TRIM$(acUserName) END IF END FUNCTION FUNCTION GetloggedOnComputer() AS STRING DIM acUserName AS ASCIIZ * 100 DIM nUserName AS LONG nUserName = SIZEOF(acUserName) IF (GetComputerName(acUserName, nUserName) = 0) THEN STDOUT "Failed to lookup computer name, error code " + STR$(GetLastError) ELSE STDOUT TRIM$(acUserName) END IF END FUNCTION FUNCTION PBMAIN() AS LONG STDOUT "User=" & GetLoggedonUser STDOUT "Comp=" & GetLoggedonComputer WAITKEY$ END FUNCTION
[This message has been edited by Wayne Diamond (edited August 15, 2001).]
Comment