?
Solved

disabling network interfaces

Posted on 2006-05-20
8
Medium Priority
?
676 Views
Last Modified: 2012-05-05
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
0
Comment
Question by:urif
  • 3
  • 3
  • 2
8 Comments
 
LVL 28

Expert Comment

by:2266180
ID: 16724089
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
 

Author Comment

by:urif
ID: 16724246
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
 
LVL 28

Expert Comment

by:2266180
ID: 16724258
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 26

Accepted Solution

by:
Russell Libby earned 400 total points
ID: 16724259
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
 
LVL 28

Expert Comment

by:2266180
ID: 16724393
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
 

Author Comment

by:urif
ID: 16724494
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
 
LVL 26

Expert Comment

by:Russell Libby
ID: 16724520

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
 

Author Comment

by:urif
ID: 16778139
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

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question