🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Help on an Undocumented call

#1913
From: Ed Mulroy
Date: Mon, 04 Jun 2007 18:30
71 lines
2977 bytes
Maybe this will help.  It's written for VB but with a little work you should 
be able to translate it to something understandable

http://tinyurl.com/ytabvg
    AKA
http://www.msfn.org/board/lofiversion/index.php/t70524.html

.  Ed

> Colin B Maharaj wrote in message
> news:46644efb@newsgroups.borland.com...
> Hi all,
> I was trying to write an interface to change an IP Address on a PC
> programatically. I used netsh and tested it in WinXP and it was OK
> The person who I wrote it for said it was not working in his environment
> which was 2000. I then did some serious digging and got the undocumented
> ip helper function called
>
> SetAdapterIpAddress
>
> which function I prototyped as ...
>
> #include "iphlpapi.h"
>
>
> typedef DWORD (WINAPI *PSETADAPTERIPADDRESS)(
> const char*,DWORD,DWORD,DWORD,DWORD
> );
>
> declared as...
> PSETADAPTERIPADDRESS SetAdapterIpAddress;
>
>
> and got a function address like......
>
> hLib = LoadLibrary("Iphlpapi.dll");
> SetAdapterIpAddress = 
> (PSETADAPTERIPADDRESS)GetProcAddress(hLib,"SetAdapterIpAddress");
>
>
> And use like this....
>
> //-------------------------------------------------------------------------------------
> #include "iphlpapi.h"
>
>
>    bool ChangeAdaptorAddress(AnsiString A, AnsiString B, AnsiString C)
>    {
>      IPAddr A1, B1, C1;
>
>      A1 = inet_addr(A.c_str());
>      B1 = inet_addr(B.c_str());
>      C1 = inet_addr(C.c_str());
>      int retvalue  = SetAdapterIpAddress(card.c_str(), 0, A1, B1, C1);
> //     ShowMessage(retvalue );
>    }
>
> In my environment, retvalue return 0
> in the 2000 environment it returns 2
>
> card is the uuid address taken from the registry.
> 0
> mean no DHCP.
>
> I know this is a toughy and no guarantees for help
> but I need to set the address without restarting the PC
>
> If anyone has an Idea how to get this working
> let me know.
>
> (2 - is like 'File Not found' or something)
Technical Details
Message-ID: <46645a5a$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!feeder3.cambrium.nl!feeder1.cambrium.nl!feed.tweaknews.nl!news2.euro.net!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <46644efb@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,838f5bf7bf191071
X-Google-Attributes: gid10cc67,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Ed Mulroy" <dont_email_me@bitbuc.ket>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <46644efb@newsgroups.borland.com>
Subject: Re: Help on an Undocumented call
Date: Mon, 4 Jun 2007 14:30:51 -0400
Lines: 73
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.3028
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3028
X-RFC2646: Format=Flowed; Response
NNTP-Posting-Host: 69.141.82.147
Message-ID: <46645a5a$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1180981850 69.141.82.147 (4 Jun 2007 11:30:50 -0700)
X-Authenticated-User: edmulroy
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!feeder3.cambrium.nl!feeder1.cambrium.nl!feed.tweaknews.nl!news2.euro.net!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail