🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #11129

Re: Problem with GetComputerName

#11129
From: Koen
Date: Mon, 23 Feb 2004 07:49
18 lines
1376 bytes
Remy Lebeau (TeamB) wrote:

> You need to initialize the value to the actual size of your buffer. 
> You are lucky the code worked at all, it very well could have crashed
> your program altogether regardless of the OS used.  Since you did not
> initialize the value, it would be initialized with random memory,
> which could have caused GetComputerName() to misuse your buffer.
> 
>     char name[MAX_COMPUTERNAME_LENGTH + 1] = {0};
>     DWORD size = MAX_COMPUTERNAME_LENGTH;
>     //...
> 

Ah, Ok. Thanks for the info, Remy! This works like a charm.

regards,

Koen
Technical Details
Message-ID: <Xns949859C0B5C05koencermbe@207.105.83.66>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <40392bec$1@newsgroups.borland.com> <40393b85$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,ac942ffac7941132
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2004-02-23 00:09:30 PST
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Re: Problem with GetComputerName
From: Koen <koen@not.this.cerm.be>
References: <40392bec$1@newsgroups.borland.com> <40393b85$1@newsgroups.borland.com>
Organization: Cerm
Message-ID: <Xns949859C0B5C05koencermbe@207.105.83.66>
User-Agent: Xnews/5.04.25
NNTP-Posting-Host: 212.224.138.242
Date: 22 Feb 2004 23:49:20 -0800
X-Trace: newsgroups.borland.com 1077522560 212.224.138.242 (22 Feb 2004 23:49:20 -0800)
Lines: 18
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail