Group: Moderators
Posts: 874
Member No.: 5019
Joined: 13-May 07
You wrote
QUOTE
nSize dd 20
Msdn say
QUOTE
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
Msdn
QUOTE
lpBuffer [out]
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
CODE
lpUsername db 257 dup (0)
Invoke GetUserName,addr lpUsername,257
or Invoke GetUserName,addr lpUsername,sizeof lpUsername