Member No.: 5019
Joined: 13-May 07
nSize dd 20
lpnSize [in, out] On input, this variable specifies the size of the lpBuffer buffer
and the size of username is 256+1
#define UNLEN 256 // Maximum user name length
and +1 for 0 end of string
now have you 257
A pointer to the buffer to receive the user's logon name. If this buffer is not large enough to contain the entire user name, the function fails. A buffer size of (UNLEN + 1) characters will hold the maximum length user name including the terminating null character. UNLEN is defined in Lmcons.h.
What if Username longer as 20 bytes?
Better you use 257 or sizeof lpUsername
lpUsername db 257 dup (0)
Invoke GetUserName,addr lpUsername,257
or Invoke GetUserName,addr lpUsername,sizeof lpUsername