Click here to Skip to main content
Email Password   helpLost your password?

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).

You must Sign In to use this message board.
 
 
Per page   
 FirstPrevNext
QuestionWindows Vista Support?
FrEaK_CH
4:55 2 May '07  
Hi

How can I run your demo application (code) on Windows Vista as a normal user? Yet, it works only when I run the WindowsFireWall.exe with 'Run as Administrator'.

Regards,
Dominik
AnswerRe: Windows Vista Support?
Tony Selke
4:59 2 May '07  
This is not something that the source code or demo application could or should allow/control. Windows Vista is enforcing that security requirement. You either have to turn off that security mechanism in Vista (not reccommended) or create a shortcut to the EXE that is configured to run as an administrator.
GeneralRe: Windows Vista Support?
FrEaK_CH
5:13 2 May '07  
Ok, I should explain a little bit more what I want to do...

I'm writing a small VPN quarantine agent based on VB.NET. One point that this agent checks is the Windows Firewall. The agent checks if the Windows Firewall is enabled (global operation mode, FirewallEnabled property of the INetFwProfile object) and also checks if the Firewall is enabled on each network interface (InternetFirewallEnabled property of the INetSharingConfiguration).

The VPN quarantine agent should run on Windows XP SP2 und Windows Vista. The users haven't local administrator rights, therefore the agent must run with normal security privilege (and the user can't select 'run as an administrator'.)


Dominik
GeneralRe: Windows Vista Support?
MFRESA
10:26 4 Aug '08  
Dominick, did you figure this out? I have the same questions.
Mark
GeneralThe connect method is not implemented...
juanm2002
8:07 5 Jul '06  
have you tried using the connect method for dialing a Dial-Up connection? I tried and it does not work. However if I dial-up manually and then use the disconnect method that method works. If you could please help me and let me know if is there any thing that needs to be done before calling connect? your help would be much appreciated.Confused Confused
GeneralRe: The connect method is not implemented...
Tony Selke
4:04 10 Jul '06  
I have not tried doing what you are attempting, since my only need was to be able to enumerate connections and toggle the state of the Windows Firewall. I am not going to have any hands-on, practical advice for you in this case.

However, I can tell you that the Connect() method is clearly implemented and linked to the underlying COM interface. So it must be getting called (can you verify this by single-stepping through the code?). However, what is happening after the call is another matter entirely.

Perhaps it would help to take a look at the Internet Connection Sharing and Internet Connection Firewall Reference for more information. I am not sure what difficulties you may be having.

Sorry I didn't have more to help.

Tony


Generalhelp me please!!!!!!
ahmed el dosoky
7:16 12 May '06  
If i have 20 PC each use WIN-XP sp2 how can i make 5 only from them can log into internet without asking the admenstrator and the rest can't use the internet even the admen allow them.
NOTE these 15 pc must still change any files and share any resource amoung the LAN(don't use any DLLs)

please help me

ahmed el-dosoky


Last Updated 6 Nov 2004 | Advertise | Privacy | Terms of Use | Copyright © CodeProject, 1999-2010