Programmatically change IP address in 9x/NT with no reboot


I would like to alter the IP address of a network card using Visual C++ without having to do a reboot.

I have found some settings in registry but these seem to require a reboot for them to take effect.

I have also found IP helper commands to do the above, but this only works for windows 2000 and onwards. This needs to work on 95/98/ME/NT4/NT2000.

Can anyone help?
Who is Participating?
jhanceConnect With a Mentor Commented:

In answer to your question, yes that certainly could be done.  I think the best approach is to implement an NDIS Intermediate driver (which goes between the top of the NDIS network card driver and below the transport drivers like TCPIP) and has access to all of the network traffic on the machine.  In essence a packet filter.  It would watch for a DHCP request, answer it itself, and could then configure whatever it wanted to configure on the local machine.

It's certainly not an impossible job but it's enough work that you're going to need a good reason for doing it.
This cannot be done without a reboot.  Windows 9x has no facility to accomplish this either via an API or via undocumented "tricks".

It is possible to accomplish this for NT4 using an undocumented API call to DchpNotifyConfigChange() in the DHCP DLL but this doesn't exist on Win9x.
I also know that this cannot be done in Win9x without a reboot. The same is true for DNS changes or other things like that. Changing IP without rebooting only exists in Win2K :)
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

>>The same is true for DNS changes...

No, the same is NOT true for DNS.  The DNS address can be changed at any time and the new value will be immediately used.
We use WinIPCFG to hot swap between 2 networks on Win98.

One network is on
the other is on

Both networks have a DHCP server

Using WinIPCFG we can unplug the cable from the network card and plug in a cable connected to the other network.

We then do release and renew with WinIPCFG and it gets a new IP address from the DHCP server on the network.

This is cleary changing IP addresses without a reboot.

>>This is cleary changing IP addresses without a reboot.

Not really.  I believe this question is about changing STATIC IP addresses which is not the same as renewing DHCP addresses.
fel080497Author Commented:
Yes, I to have used WinIPcfg and ipconfig to renew DHCP addresses. But what I need is to be able to change static IP addresses.

So just what is the difference between DHCP changing the IP address and changing a static IP address. SUrely if DHCP can do it, then so can we!

Perhaps I dont understand the difference between the two?
For whatever reason, the way Microsoft designed the TCPIP stack in Win95, 98, and ME, it CANNOT change from one static IP to another, from DHCP to static, or from static to DHCP without a reboot.  It simply cannot be done.

There is no technical reason why it could not be designed to be possible as NT4 and Win2000 prove.

DHCP is handled differently in the driver and needs to reboot.
>>So just what is the difference between DHCP changing the
>>IP address and changing a static IP address.
>> SUrely if DHCP can do it, then so can we!

I guess DHCP is built around the idea of renewal and that it would need to support the possibility that an IP address could change.

Maybe MS just got lazy in this case and found that the static and dynamic portions of the 9x stacks were incompatible?  (maybe written by different teams?)

Maybe their is a very good 9x reason for it - who knows?

fel080497Author Commented:
Hmmm, thank you microsoft is all I can say!!

This may sound a bit wacky, but do you know if a mini DHCP server could be written to run on the machines that is having the IP address changed. So that when they request a new IP address this responds with the new IP address which is then assigned using DHCP? Then in theory you could swap between two fixed addresses.

Can you run a DHCP server on the same machine that is requesting a new IP address? and is there a way of making the machine goto its own specific DHCP server?

Otherwise it looks like an upgrade to win2000 will have to be done in order to have this funcionality. (Nice one microsoft)
fel080497Author Commented:
Oh well thanks for answering, it may not have been the answer I was looking for but at least it confirmed my suspicions.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.