title: Delphi and WMI Networking
body: <p>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:</p>
  
  <p><a href="http://delphi.borlandforum.com/impboard/impboard.dll?action=read&amp;db=del_tip&amp;no=204" rel="nofollow">SetIPConfig</a></p>
  
  <p>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:</p>
  
  <blockquote>
    <p>94 Path, file, or object not found</p>
  </blockquote>
  
  <p>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).</p>
  
  <p>HERE IS DESCRIBED EXACTLY MY PROBLEM:</p>
  
  <p><a href="http://www.neowin.net/forum/topic/515984-c-enabling-dhcp-on-nic-through-wmi/" rel="nofollow">http://www.neowin.net/forum/topic/515984-c-enabling-dhcp-on-nic-through-wmi/</a></p>
  
  <p>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.  </p>
  
  <p>Here another topic related:</p>
  
  <p>www.winvistatips.com/wmi-config-fails-ethernet-cable-unplugged-t181330.html</p>
  
  <p>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.</p>
  
  <p>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. </p>
  
  <p>OS: XP SP3
  Language:DelphiXE</p>
  
  <p>What's wrong ?
  Many thanks.</p>