WinAsm Studio, The Assembly IDE - Free Downloads, Source Code
Sponsors
Articles
Programming Quick Start
32-bit Assembler is Easy
Porting Iczelion tutorials
What is FASM
Hard Drive Recovery
Wiring your own LAN
Personal menu
Welcome Guest
User:
Pass:
Register!
Resend Validation Email
 
Forum
Pages (3) 1 2 [3]   ( Go to first unread post )

How to use GetComputerName API, I am new to asm can anyone help how to use GetComputerName API in masm?

ragdog
Quote Post


Extremely Active Member
******

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? wink.gif

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


Greets,

PMUsers Website
Top
winnet
Quote Post


Member
**

Group: Members
Posts: 20
Member No.: 41214
Joined: 18-January 11


Yeah You are right Ragdog

I ignored it when I was explaining wsprintf

I should use max Length wink.gif
PMEmail Poster
Top
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

Topic Options Pages (3) 1 2 [3]  Reply to this topicStart new topicStart Poll

 

Sponsors
Computer Science

Internet
C/C++
Hardware & PC maintenance

HiEditor

General Discussions
Suggestions/Bug Reports
WinAsm Studio

General Discussions
Suggestions/Bug Reports
WinAsm Studio FAQ
Multilingual User Interface
Add-Ins
Assembly Programming

Main
Newbies
Projects
Custom Controls
Snippets
Announcements & Rules

Announcements

General

Online Degrees - Distance Learning
The Heap
Russian
Google