disabling network interfaces

hi, part of an application i'm writing needs to disable all network interfaces before installing an update.
i searched quite a bit but i couldn't come up with any examples of any Win32 API that can allow me to do that.
so basically what i'm looking a way to disable by code (sort of like doing right-click on the interface icon and click disable) all the network interfaces. if possible no 3rd party vcls or huge units. code will be appreaciated.
thanks
urifAsked:
Who is Participating?
 
Russell LibbySoftware Engineer, Advisory Commented:
Delphi code for network interface handling (includes enabling/disabling). It does require a few jedi tag along units.

http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_21237093.html

Regards,
Russell
0
 
2266180Commented:
you can use WMI to acomplish this. I did a quick investigation and using WIN32_NetworkAdapter 's NetEnabled property (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/win32_networkadapter.asp) setting it to false, should disable the network adapter. If you are not familiar with WMI then look at the page http://www.ciuly.com/delphi/wmi/settingUpWmi/index.html on how to setup your environment to use WMI; then you can look at the other examples to see how to work with WMI.
If you think you can't handle it, don't have time for it, then let me know and I'll try to do it for you in the next hour or so.
0
 
urifAuthor Commented:
thanks for the help. i went thru the explanation on the msdn but still, i can't figure how to do it, specially without having to install wmi. i just need to be able to disable/enable a network adapter, i don't know why i need to install around 12mb and an sdk and translate code from C to delphi in order to do that. there must be a shortest and easiest way.
in any case i appreaciate the help, any code to do just that: disable/enable a network interface
0
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

 
2266180Commented:
well .. you only have to install a runtime wmi (not sdk) and only on win95/98 and winnt. win2000 and later come with WMI installed.
then you have to setup delphi to use wmi which is pretty simple and explained on my page with setting up wmi. (it only takes about 5 min and it's done only once per delphi installation)
AND there is no C code to be translated to delphi. as you can see on the other examples, it's only COM/OLE in delphi. no C needed.
I'll make an example app and post a link to it in about 15-30 min.
0
 
2266180Commented:
hm ... it seems that I overlooked the note on that netenabled property. it's not available in win2003 or later.
But since I made the program to show the status of the network adapter, here is the source just for the sake of it :)
http://www.ciuly.com/delphi/wmi/networkAdapterStatus/index.html
since rllibby already gave a pretty good solution, I will not try to find another one using WMI :) for all I know it might not even be possible with current implementation on winxp.

cheers
0
 
urifAuthor Commented:
thanks ciuly and rllibby, let me try it and i'll get back to you.

i was trying to get the code working "without" the use of 3rd parties components (the jedi's code), it usually consists on a hug amount of code and i only need one of the functions... anyway...
0
 
Russell LibbySoftware Engineer, Advisory Commented:

The jedi code was used because I was to lazy to create delphi translations for the the API calls and the structures required (they already had it done), but you should find that there is minimal overhead for including the units in this situation.

Russell
0
 
urifAuthor Commented:
hi, i run into a problem. since this program will be running in different computers i can't hard code the GUID for the NIC, it has to be on the fly. any ideas on how to do this?

thanks, and sorry for the mess
0
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.