🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: getadaptersinfo....

#11516
From: derek
Date: Fri, 06 Feb 2004 16:06
89 lines
3171 bytes
Thanks Ed, i had a couple of goes at reading the description
for this...now it makes sense :-) cheers derek 

"Ed Mulroy [TeamB]" <dont_email_me@bitbuc.ket> wrote:
>If you look at the docs on that function one of the reasons for the invalid
>parameter return value is for the situation where you do not own the memory
>at the address given.  By convention your program does not own the NULL
>address, it is an invalid addres, so the error makes sense.  Put the address
>of something in there.  Here is an example I ran just to illustrate:
>
>  ------------------
>  C:\Documents and Settings\Administrator\My Documents\Lookat\Temp
>  >type temp5.cpp
>
>  #include <windows.h>
>  #include <iphlpapi.h>
>  #include <stdio.h>
>
>  const char *GetReason(DWORD val)
>    {
>    char *msg;
>
>    switch (val)
>      {
>      case ERROR_BUFFER_OVERFLOW :
>        msg = "ERROR_BUFFER_OVERFLOW";
>        break;
>      case ERROR_INVALID_PARAMETER :
>        msg = "ERROR_INVALID_PARAMETER";
>        break;
>      default :
>        msg = "Other message";
>        break;
>      }
>
>    return msg;
>    }
>
>  int main()
>    {
>    unsigned long ulAdapterSize=0;
>
>    DWORD result = GetAdaptersInfo(NULL, &ulAdapterSize);
>
>    printf("NULL gives %s\n", GetReason(result));
>
>    char c;
>
>    result = GetAdaptersInfo((PIP_ADAPTER_INFO) &c, &ulAdapterSize);
>    printf("&char gives %s\n", GetReason(result));
>
>    return 0;
>    }
>
>  C:\Documents and Settings\Administrator\My Documents\Lookat\Temp
>  >ver
>
>  Microsoft Windows XP [Version 5.1.2600]
>
>  C:\Documents and Settings\Administrator\My Documents\Lookat\Temp
>  >temp5
>  NULL gives ERROR_BUFFER_OVERFLOW
>  &char gives ERROR_INVALID_PARAMETER
>
>  C:\Documents and Settings\Administrator\My Documents\Lookat\Temp
>  >
>  ------------------
>
>.  Ed
>
>> derek wrote in message
>> news:40237638$1@newsgroups.borland.com...
>>
>> Does any one know why the call to GetAdaptersInfo returns:
>>
>> ERROR_BUFFER_OVERFLOW on my Win2k machine...but
>> ERROR_INVALID_PARAMETER on an XP machine?
>>
>> I'm using CB5 pro on both machines.
>>
>> ULONG ulAdapterSize=0;
>>
>> if(GetAdaptersInfo(NULL, &ulAdapterSize) ==
>>  ERROR_BUFFER_OVERFLOW)
>> {
>> <--SNIP-->
>
>
Technical Details
Message-ID: <4023bb78$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <40237638$1@newsgroups.borland.com> <4023b4e7$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,ce3424bce4f1c00e
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2004-02-06 08:10:38 PST
From: "derek" <derek@home.com>
Sender: "derek" <derek@home.com>
Reply-To: "derek" <derek@home.com>
Subject: Re: getadaptersinfo....
Newsgroups: borland.public.cppbuilder.nativeapi
X-User-Info: 47.211.0.12     
References: <40237638$1@newsgroups.borland.com> <4023b4e7$1@newsgroups.borland.com>
NNTP-Posting-Host: 207.105.83.66
Message-ID: <4023bb78$1@newsgroups.borland.com>
Date: 6 Feb 2004 08:06:16 -0800
X-Trace: newsgroups.borland.com 1076083576 207.105.83.66 (6 Feb 2004 08:06:16 -0800)
Lines: 90
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail