UDF-GetUserName
Keywords: UDF-GetUserName
Get the current logged on user:#DefineFunction GetUserName() dllname=strcat(dirwindows(1),"Advapi32.DLL") bufsize=100 PTRBB=BinaryAlloc(bufsize) ; allocate a memory buffer of n bytes PTRNAM=BinaryAlloc(4) BinaryPoke4(PTRNAM,0,bufsize) DllCall(dllname, long:"GetUserNameA", lpbinary:PTRBB, lpbinary:PTRNAM) BinaryEODSet(PTRBB,100) ; set the end of username=BinaryPeekStr(PTRBB, 0, 100) BinaryFree(PTRBB) BinaryFree(PTRNAM) return (username) #EndFunction userid=GetUserName() Message("Userid",userid)
Article ID: W15326