>>FUNCTION GetCompName >>* Declare the API function >>DECLARE INTEGER GetComputerName IN Win32API ; >> STRING @cComputerNameBuffer, ; >> INTEGER @nLengthOfName >>LOCAL cMyBuffer, nBufferLen, nResult, cReturnVal >>* >>* Create a fixed-length buffer to hold result; we'll examine the buffer length >>* after the call to see how long the name really is - under Win32, it shouldn't exceed 15 chars + null >>* >>cMyBuffer = SPACE(255)+CHR(0) >>nBufferLen=256 >>* >>* Note how seriously I believe the values in the VC .h files! >>* >>nResult = GetComputerName(@cMyBuffer, @nBufferLen) >>IF nResult = 1 >> cReturnVal=STRTRAN(LEFT(cMyBuffer,nBufferLen),CHR(0),'') >>ELSE >> cReturnVal = '' >>ENDIF >>RETURN cReturnVal >>>
DECLARE INTEGER GetUserName IN Win32API ; STRING @cUserNameBuffer, ; INTEGER @nLengthOfNameYou'll need to user WNetGetUser() to get how they're logged into other resources:
DECLARE INTEGER WNetGetUser IN Win32API ; STRING @cRemoteResourceName, ; STRING @cRemoteUserNameBuffer, ; INTEGER @nLengthOfUserName