🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Retrieving Address info from GetAdaptersInfo

#13168
From: Remy Lebeau (TeamB)
Date: Thu, 23 Oct 2003 08:15
37 lines
2077 bytes
"Maurice Anderson" <mauriceanderson@hotmail.com> wrote in message
news:3f978730$1@newsgroups.borland.com...

> Yes I did as : pinfo = NULL;

That is not what I meant.  You need to allocate actual memory for the
structure before you can fill it.  GetAdaptersInfo() can return the
necessary size for the structure so that you can then allocate enough memory
for it, ie:

    ULONG BufLen = 0;
    GetAdaptersInfo(NULL, &BufLen);
    if( BufLen )
    {
        PIP_ADAPTER_INFO pinfo = (PIP_ADAPTER_INFO)GlobalAlloc(GPTR,
BufLen);
         if( pinfo )
        {
            GetAdaptersInfo(pinfo, &BufLen);

            // use pinfo as needed...

            GlobalFree(pinfo);
        }
    }

> I tried the ARRAYOFCONST macro and the compiler errors
> went away, however, I don't get any data when I do a:
> ShowMessage(m_macaddress);

Your code should have crashed before you got that far since you are using an
invalid pointer.  You should also be checking GetAdaptersInfo() return value
to make sure that it even returns valid data before you try to use it.


Gambit
Technical Details
Message-ID: <3f978da1$2@newsgroups.borland.com>
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: <3f977b4f@newsgroups.borland.com> <3f977d1e@newsgroups.borland.com> <3f978730$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,90790ba1c056df66
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-10-23 01:39:17 PST
From: "Remy Lebeau \(TeamB\)" <gambit47.no.spam@no.spam.yahoo.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <3f977b4f@newsgroups.borland.com> <3f977d1e@newsgroups.borland.com> <3f978730$1@newsgroups.borland.com>
Subject: Re: Retrieving Address info from GetAdaptersInfo
Date: Thu, 23 Oct 2003 01:15:56 -0700
Lines: 39
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.137.75
Message-ID: <3f978da1$2@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1066896801 67.22.137.75 (23 Oct 2003 01:13:21 -0700)
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