for an application i'm writing, i need to change some parameters of the network adapter, including enabling/disabling DHCP. For this purpose, i'm using the "SetIpConfig" command from this source code:
It works very well and does what i need if the network adapter is connected. The problem is that i cannot enable DHCP if the LAN cable is unplugged, while i can correctly change other parameters such as IP or Gateway. When i try to enable dhcp, while network adapter is disconnected, i get the ole error:
94 Path, file, or object not found
I think it should work anyway, even if the network card is disconnected, because i can do this correctly, going into the network card/ip properties window (using XP).
HERE IS DESCRIBED EXACTLY MY PROBLEM:
http://www.neowin.net/forum/topic/515984-c-enabling-dhcp-on-nic-through-wmi/
as that guy did, i tried to change directly the register keys to activate the DHCP but, even if on the network adapter properties, the value was changed correctly, the NIC behaved like nothing was changed, like the changes were not "applied" to it.
Here another topic related:
www.winvistatips.com/wmi-config-fails-ethernet-cable-unplugged-t181330.html
They suggest to disable dhcpsense putting a key into HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters named DisableDHCPMediaSense (DWORD) and setting it to 1.
Ok..it works now, i didn't try the full dhcp functionality, just i've seen that it can be enabled with nic unplugged but, as someone wrote, i don't think disabling dhcp sense is a great idea. It means that the dhcp client cannot know the connection status, so i think that it could have troubles in renewing leases if the connection drops, then is estabilished again.
OS: XP SP3 Language:DelphiXE
What's wrong ? Many thanks.
this way
. It will confirm the right answer to the future visitors with the same problem. Thanks!