Code: Select all
*mem=AllocateMemory(1000)
buff.w=1000
GetUserName_(*mem,buff)
Debug PeekS(*mem)
FreeMemory(*mem)
Please help.

Code: Select all
*mem=AllocateMemory(1000)
buff.w=1000
GetUserName_(*mem,buff)
Debug PeekS(*mem)
FreeMemory(*mem)
Code: Select all
Name.s=Space(500)
NameLen=Len(Name)
GetUserName_(@Name,@NameLen)
Debug Name
GetUserName_() requires a pointer to an empty string buffer AND a pointer to the length of this buffer. You need to change your code this way or use droopy's code which is much more handy.The Mexican wrote:After looking at the API I found that the GetUsername function should return the username of the current logged user.
After compiling this code I get an "invalid memory access" error.Code: Select all
*mem=AllocateMemory(1000) buff.w=1000 GetUserName_(*mem,buff) Debug PeekS(*mem) FreeMemory(*mem)
Please help.
Code: Select all
mem=AllocateMemory(1000)
buff.w=1000
GetUserName_(*mem,@buff)
Debug PeekS(*mem)
FreeMemory(*mem)