Can any one please tell me how can i compare the Username of user currently
logged on the system with a predifined Username to verify the User
I used API "GetUserName" but i am not able to compare it with a predifined user
I have attached the code below please tell me where I am going wrong.
If possible please modify the code and re-attach it Thankx.
------------==================================--------------

includelib \masm32\lib\advapi32.lib

.data

buffer dd 64
ubuff dd ?
Caption db "Current User is:-",0
pp db "XYZ",0
bad db "Invalid!",0
bad2 db "UserName's Dont Match!",0

.code



start:

invoke GetUserName,ADDR ubuff,ADDR buffer
.if ubuff==pp
invoke MessageBox,NULL,ADDR ubuff,ADDR Caption,MB_OK
invoke ExitProcess,NULL
.else
invoke MessageBox,NULL,ADDR bad,ADDR bad2,MB_OK
invoke ExitProcess,NULL
.endif
End start
Posted on 2003-04-14 10:09:41 by telophase
it doesn't really work that way :)

use StrCmp on both values to see if they're the same and branch according to that

so




includelib \masm32\lib\advapi32.lib

.data

buffer dd 64
ubuff dd ?
Caption db "Current User is:-",0
pp db "XYZ",0
bad db "Invalid!",0
bad2 db "UserName's Dont Match!",0

.code



start:

invoke GetUserName,ADDR buffer,63
invoke StrCmp, addr buffer, addr pp

.if eax == 0 ; strings are equal
invoke MessageBox,NULL,ADDR ubuff,ADDR Caption,MB_OK
invoke ExitProcess,NULL
.else
invoke MessageBox,NULL,ADDR bad,ADDR bad2,MB_OK
invoke ExitProcess,NULL
.endif
End start

Posted on 2003-04-14 11:32:38 by Hiroshimator