Article View: borland.public.cppbuilder.nativeapi
Article #11276Re: Problem with GetComputerName
From: Remy Lebeau (TeamB)
Date: Sun, 22 Feb 2004 23:38
Date: Sun, 22 Feb 2004 23:38
18 lines
1488 bytes
1488 bytes
"schoene" <email@email.com> wrote in message
news:40392bec$1@newsgroups.borland.com...
> unsigned long size;
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;
//...
Gambit
Technical Details
Message-ID:
<40393b85$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!news.belwue.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<40392bec$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-22 15:39:38 PST From: "Remy Lebeau \(TeamB\)" <gambit47.no.spam@no.spam.yahoo.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <40392bec$1@newsgroups.borland.com> Subject: Re: Problem with GetComputerName Date: Sun, 22 Feb 2004 15:38:19 -0800 Lines: 20 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 NNTP-Posting-Host: 67.22.138.253 Message-ID: <40393b85$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1077492613 67.22.138.253 (22 Feb 2004 15:30:13 -0800) Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!news.belwue.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail