Click here to Skip to main content
13,152,321 members (40,938 online)
Click here to Skip to main content
Add your own
alternative version


10 bookmarked
Posted 24 Aug 2007

Exploring Network Configuration with the INetCfg COM Interface

, 24 Aug 2007
Rate this:
Please Sign up or sign in to vote.
Getting information about installed network drivers on a PC.

Screenshot - Driver_Found.jpg


To get information about the installed network devices, the COM interface INetCfg and some other interfaces can be used.


My problem was to prove that a special driver is available on a PC. For that, I looked at the snetcfg.exe sample from Microsoft, but it didn't work for me. So, I explored the code and found that it used the INetCfg COM interface. But, I didn't find good documented code at all, so I made myself a class.

Using the Code

For using the code, it is essential to have the SDK and the DDK (or WDK) from Microsoft to have all the files installed and the right paths set so all the files can be found. I have made remarks on the most important areas:

#include <Netcfgx.h>
#include <comdef.h>
//Platform SDK
#include <devguid.h>

Before using it, you got to create the internal COM objects. If it doesn't work, may be COM errors can help you.

//Creating the COM-instance
m_NetCfg.Init( L"Codeproject Sample", false );

My final use:

is to check whether a driver can be accessed via the COM interfaces:

HRESULT hr = m_NetCfg.FindComponentDisplayName( bs, csDisplay );
if( IS_OK( hr ) )
    cs.Format( "Driver found. Displayname is %s", csDisplay );
    cs.Format( "Error in NetCfg. COM-Message: %s", m_NetCfg.GetLastErrorMessage() );

In the error part, you can see my error text function used to enhance usability.

Points of Interest

It was fun to see COM work for me as I wrote the code. Because I didn't find much at CP about INetCfg, I decided to publish this article. I hope it helps, as I have often found help here.


  • 1.0: 23 Aug., 2007: Initial release.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Software Developer
Germany Germany
I am living in germany and now living from programming for some Years. In my spare time I like sports as jogging, playing football (soccer) and basketball.

We must take care for our planet, because we and our family has no other. And everybody has to do something for it.

You may also be interested in...


Comments and Discussions

GeneralMy vote of 1 Pin
dxlee6-Oct-09 3:56
memberdxlee6-Oct-09 3:56 
GeneralHard stuff, INetCfg! Pin
Iain Clarke30-Sep-08 0:12
memberIain Clarke30-Sep-08 0:12 
GeneralRe: Hard stuff, INetCfg! Pin
KarstenK30-Sep-08 0:57
memberKarstenK30-Sep-08 0:57 
GeneralRe: Hard stuff, INetCfg! Pin
Iain Clarke30-Sep-08 1:16
memberIain Clarke30-Sep-08 1:16 
GeneralHi Pin
iknownoone22-Oct-07 9:19
memberiknownoone22-Oct-07 9:19 
GeneralRe: Hi Pin
KarstenK22-Oct-07 20:41
memberKarstenK22-Oct-07 20:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.170924.2 | Last Updated 24 Aug 2007
Article Copyright 2007 by KarstenK
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid