473,398 Members | 2,380 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

detecting enabled network interfaces in win32

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
4 3584
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: SenderX | last post by:
I am a basically a life-long Win32 C programmer specializing in high-end winsock servers. Before I dive into portable C++ programming, I wanted to code up an example of what I thought would be a...
5
by: Rich | last post by:
I have a simple, single threaded program in C++ that runs as Idle priority. The program creates some data which needs dumping to file if the computer is shutdown or logged out. At the moment...
25
by: Ryan Stewart | last post by:
I'm working on a project to collect web application usage statistics. What are the recommended ways of detecting whether a browser is JavaScript enabled and/or capable? Obviously I can write a...
7
by: wij | last post by:
Hi: Is there better way of detecting multiplication overflow for type long than by using double precision of lldiv to verify the result? Thanks in advance. I.J.Wang
3
by: Scott Leonard | last post by:
Hello - I'm writing an application that will be used on "sometimes connected" devices (laptops, tablets). In C#, what is the best way to detect whether a network connection is present? I'd...
1
by: Daniel Diehl | last post by:
Hi, I'm looking for a solution to detect if a USB Sticker (USB Drive) ist plugged in or plugged out. Currently Im able to detect Hardware Plugin and Plugout but don't get any information what type...
17
by: OlafMeding | last post by:
Below are 2 files that isolate the problem. Note, both programs hang (stop responding) with hyper-threading turned on (a BIOS setting), but work as expected with hyper-threading turned off. ...
15
by: RobG | last post by:
When using createEvent, an eventType parameter must be provided as an argument. This can be one of those specified in DOM 2 or 3 Events, or it might be a proprietary eventType. My problem is...
12
by: Anic297 | last post by:
Hi, This is certainly a simple question, but I'm a newbie in JavaScript. Is there a way to know if JavaScript is enabled? My php script uses JavasSript to do something. If JavaScript is not...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.