By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,389 Members | 2,044 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,389 IT Pros & Developers. It's quick & easy.

detecting enabled network interfaces in win32

P: n/a
In one of my "because I can" projects, I want to be able to see the
enabled network interfaces on a machine. I have no clue as to how to
do this. Any suggestions?
Jul 18 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
In one of my "because I can" projects, I want to be able to see the
enabled network interfaces on a machine. I have no clue as to how to
do this. Any suggestions?


Parse the output of 'ipconfig /all' on NT/2k/XP/2k3 machines.
I'm sure it is available in the registry, I've been there before, but I
can't remember the key name. Use regedit to find the key with your
network interface to determine where you should be polling in general.
- Josiah

Jul 18 '05 #2

P: n/a
ma**********@gmail.com (Matthew K Jensen) wrote in message news:<a8**************************@posting.google. com>...
In one of my "because I can" projects, I want to be able to see the
enabled network interfaces on a machine. I have no clue as to how to
do this. Any suggestions?


Use the WSAIoctl function of Winsock2 with the command (2nd parameter)
dwIoControlCode = SIO_GET_INTERFACE_LIST.

The other key important tidbit of information would be that you will
need to pass the address of an array of INTERFACE_INFO structures to
the output buffer (5th parameter - lpvOutBuffer) to obtain structures
containing the information you desire.

Below are links to the MSDN documentation of both the WSAIoctl
function and the INTERFACE_INFO structure.

Documentation for WSAIoctl:
http://msdn.microsoft.com/library/de...wsaioctl_2.asp
Documentation for INTERFACE_INFO:
http://msdn.microsoft.com/library/de...ace_info_2.asp

I don't that this function is exposed through any of the win32 python
extensions, although I have not had time to research this in order to
be sure.

For that reason, you would likely have to access this method using
ctypes.

Enjoy, and please let me know when you've written such a script
because I'd love to use it. =)

Michael Loritsch
Jul 18 '05 #3

P: n/a
If you have pywin32 installed, you can get the info thru WMI:

import win32com.client
wmi=win32com.client.GetObject('winmgmts:')
adapters=wmi.InstancesOf('win32_networkadapter')
for adapter in adapters:
for p in adapter.Properties_:
print p.Name, p.Value

hth
Roger

"Matthew K Jensen" <ma**********@gmail.com> wrote in message
news:a8**************************@posting.google.c om...
In one of my "because I can" projects, I want to be able to see the
enabled network interfaces on a machine. I have no clue as to how to
do this. Any suggestions?

Jul 18 '05 #4

P: n/a
ma**********@gmail.com (Matthew K Jensen) wrote in message news:<a8**************************@posting.google. com>...
In one of my "because I can" projects, I want to be able to see the
enabled network interfaces on a machine. I have no clue as to how to
do this. Any suggestions?


Try this:

http://tgolden.sc.sabren.com/python/...l#ip_addresses

TJG
Jul 18 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.