2

i'm looking for a way to enable or disable dhcp on a network interface via win32 api. actually i solve this by using wmi but i would like to do this via win32 api because i would like to workaround corrupted wmi's.

i found a thread where they do this via registry api: On enabling Network adpater, Autoconfiguration IP address getting set but is this the only way to achieve?

cheers, ceth

5
  • 1
    Direct registry approaches are going to be fragile. WMI is probably the only sane way to do it, unless there is a non-registry API, which I'm not aware of, unless it's this API: SCAPI (setup and configuration API). I know how to do that in Delphi thanks to this library: sourceforge.net/projects/jedi-apilib You might check it and find the names of the SCAPI functions from there. Commented Mar 9, 2013 at 22:58
  • so how would you do this with this library? i found a big amount of win32 api function mappings. but the only dhcp related functions i found are the ones from the dhcp client/server api which has no functions for enable/disable dhcp on network adapters. Commented Mar 9, 2013 at 23:35
  • 1
    You want to find the Setup API that will enumerate a class ID for network adapters. Then you want to enumerate configuration properties for that ethernet adapter. That's all I know. Figure it out yourself! Commented Mar 10, 2013 at 14:57
  • 1
    Is shelling out to netsh.exe an option? Commented Mar 15, 2013 at 4:26
  • i finally did it with wmi and shelling out netsh.exe as a backup if wmi is not working. the way over the win32 api is quite too unhandy... Commented Aug 27, 2013 at 9:19

1 Answer 1

1

i finally did it with wmi and shelling out netsh.exe as a backup if wmi is not working. the way over the win32 api is quite too unhandy..

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.