Click here to Skip to main content
6,594,932 members and growing! (16,307 online)
Email Password   helpLost your password?
General Programming » Internet / Network » Internet     Intermediate License: The Code Project Open License (CPOL)

Using the Internet Connection Sharing (ICS) and Internet Connection Firewall (ICF) COM Interfaces

By Tony Selke

The NetworkConnectionCollection is a strongly-typed interface that is meant to simplify access to the Internet Connection Sharing and Internet Connection Firewall interfaces for each of the network connections registered on the machine.
VB.NET 1.1, WinXP, COM, WinForms, VS.NET2003, Dev
Posted:6 Nov 2004
Views:34,047
Bookmarked:25 times
Announcements
Loading...
 
Search    
Advanced Search
Add to IE Search
printPrint   add Share
      Discuss Discuss   Broken Article?Report  
10 votes for this article.
Popularity: 4.25 Rating: 4.25 out of 5

1
1 vote, 10.0%
2
4 votes, 40.0%
3
1 vote, 10.0%
4
4 votes, 40.0%
5

Sample Image - NetConColDemo.png

Introduction

With the release of Windows XP's Service Pack 2, Microsoft's Internet Connection Sharing (ICS) and Internet Connection Firewall (ICF) features quickly obtained a large degree of notoriety. Many developers have been actively looking for ways to easily "peek and poke" at the ICS & ICF configurations on a given machine.

The good news is that Microsoft released the interfaces with a COM wrapper. The bad news is that it isn't well advertised and it's not very intuitive to use. Getting a full set of details on a particular connection's configuration can require several method calls.

Overview

This project contains a strongly-typed collection named NetworkConnectionCollection. When you create an instance of this collection, it automatically uses the ICS/ICF COM interfaces to iterate all of the Network Connections on the local machine and create NetworkConnection objects (as members of the NetworkConnectionCollection).

The NetworkConnection class impliments three ICS/ICF interfaces: INetConnection, INetConnectionProps and INetSharingConfiguration. When you use the ICS/ICF COM interfaces directly, you need to reference each of these independantly. By using the NetworkConnection class, you can access all of the members in one place.

Work Remaining

I haven't spent much time on this, since it does what I need at this point. One obvious improvement would be to overload a few of the members to expose/use native types (e.g. the INetConnectionProps.GUID property returns a String, but a System.Guid would be preferable). Another improvement would be to wrap the PortMappings.

References

Microsoft has exposed the API for the ICS & ICF in a couple of places, but this code uses the COM interface HNetCfg.HNetShare. You can add a reference to this interface to your own projects by using the Reference Browser to select HNETCFG.DLL (typically located in the "C:\Windows\System32\" directory).

License

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

About the Author

Tony Selke


Member
Tony Selke is an independant consultant who has spent the last 16 years working with Microsoft technologies (VB, VC++, ASP, J++, C#, VB.NET, SQL Server, etc.) to develop solutions used in all kinds of market verticals (industrial, pharmaceutical, financial, marketing, multimedia, educational, telecommunications, etc.). He obtained his first MCSD certification in 1998 and his second in 2004, with an MCDBA in 2005. In addition, he has taught courses for MCSD certification students as well as programming classes at Penn State University.
Occupation: Architect
Company: Wyvern Software
Location: United States United States

Other popular Internet / Network articles:

Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 7 of 7 (Total in Forum: 7) (Refresh)FirstPrevNext
QuestionWindows Vista Support? PinmemberFrEaK_CH4:55 2 May '07  
AnswerRe: Windows Vista Support? PinmemberTony Selke4:59 2 May '07  
GeneralRe: Windows Vista Support? PinmemberFrEaK_CH5:13 2 May '07  
GeneralRe: Windows Vista Support? PinmemberMFRESA10:26 4 Aug '08  
GeneralThe connect method is not implemented... Pinmemberjuanm20028:07 5 Jul '06  
GeneralRe: The connect method is not implemented... PinmemberTony Selke4:04 10 Jul '06  
Generalhelp me please!!!!!! Pinmemberahmed el dosoky7:16 12 May '06  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 6 Nov 2004
Editor: Nishant Sivakumar
Copyright 2004 by Tony Selke
Everything else Copyright © CodeProject, 1999-2009
Web21 | Advertise on the Code Project