Index: /trunk/src/VBox/Devices/Makefile.kmk
===================================================================
--- /trunk/src/VBox/Devices/Makefile.kmk	(revision 13719)
+++ /trunk/src/VBox/Devices/Makefile.kmk	(revision 13720)
@@ -173,4 +173,8 @@
 endif
 
+ifdef VBOX_WITH_NETFLT
+VBoxDD_LIBS.win       += $(PATH_LIB)/WinNetConfig.lib
+endif
+
 ifeq ($(KBUILD_TARGET),solaris)
  VBoxDD_LIBS           += adm
@@ -191,5 +195,4 @@
 VBoxDD_LDFLAGS.linux    = -Wl,--no-undefined
 VBoxDD_LDFLAGS.l4       = -Wl,--no-undefined
-
 
 #
Index: /trunk/src/VBox/HostDrivers/VBoxNetFlt/Makefile.kmk
===================================================================
--- /trunk/src/VBox/HostDrivers/VBoxNetFlt/Makefile.kmk	(revision 13719)
+++ /trunk/src/VBox/HostDrivers/VBoxNetFlt/Makefile.kmk	(revision 13720)
@@ -111,4 +111,13 @@
  endif # signing
 
+#
+# WinNetConfig - static library with host network interface config API
+#
+LIBRARIES.win += WinNetConfig
+WinNetConfig_TEMPLATE         = VBOXR3STATIC
+WinNetConfig_DEFS     = _WIN32_WINNT=0x0500 _UNICODE UNICODE
+WinNetConfig_SDKS     = WINPSDK W2K3DDK
+WinNetConfig_SOURCES         = \
+	win/WinNetConfig.cpp
 
 else if1of ($(KBUILD_TARGET), linux solaris)
Index: /trunk/src/VBox/Main/HostImpl.cpp
===================================================================
--- /trunk/src/VBox/Main/HostImpl.cpp	(revision 13719)
+++ /trunk/src/VBox/Main/HostImpl.cpp	(revision 13720)
@@ -119,5 +119,5 @@
 
 #if defined(RT_OS_WINDOWS) && defined(VBOX_WITH_NETFLT)
-# include <Netcfgn.h>
+# include <VBox/WinNetConfig.h>
 #endif /* #if defined(RT_OS_WINDOWS) && defined(VBOX_WITH_NETFLT) */
 
@@ -706,153 +706,4 @@
 #if defined(RT_OS_WINDOWS) && defined(VBOX_WITH_NETFLT)
 # define VBOX_APP_NAME L"VirtualBox"
-# define VBOX_NETCFG_LOCK_TIME_OUT     5000
-
-/*
-* Release reference
-*/
-static VOID vboxNetCfgWinReleaseRef (IN IUnknown* punk)
-{
-    if(punk)
-    {
-        punk->Release();
-    }
-
-    return;
-}
-
-/*
-* Get a reference to INetCfg.
-*
-*    fGetWriteLock  [in]  If TRUE, Write lock.requested.
-*    lpszAppName    [in]  Application name requesting the reference.
-*    ppnc           [out] Reference to INetCfg.
-*    lpszLockedBy   [in]  Optional. Application who holds the write lock.
-*
-* Returns:   S_OK on sucess, otherwise an error code.
-*/
-static HRESULT vboxNetCfgWinQueryINetCfg (IN BOOL fGetWriteLock,
-                    IN LPCWSTR lpszAppName,
-                    OUT INetCfg** ppnc,
-                    OUT LPWSTR *lpszLockedBy)
-{
-    INetCfg      *pnc = NULL;
-    INetCfgLock  *pncLock = NULL;
-    HRESULT      hr = S_OK;
-
-    /*
-    * Initialize the output parameters.
-    */
-    *ppnc = NULL;
-
-    if ( lpszLockedBy )
-    {
-        *lpszLockedBy = NULL;
-    }
-    /*
-    * Create the object implementing INetCfg.
-    */
-    hr = CoCreateInstance( CLSID_CNetCfg,
-                            NULL, CLSCTX_INPROC_SERVER,
-                            IID_INetCfg,
-                            (void**)&pnc );
-    if ( hr == S_OK )
-    {
-
-        if ( fGetWriteLock )
-        {
-
-            /*
-            * Get the locking reference
-            */
-            hr = pnc->QueryInterface( IID_INetCfgLock,
-                                        (LPVOID *)&pncLock );
-            if ( hr == S_OK )
-            {
-                /*
-                * Attempt to lock the INetCfg for read/write
-                */
-                hr = pncLock->AcquireWriteLock( VBOX_NETCFG_LOCK_TIME_OUT,
-                                                    lpszAppName,
-                                                    lpszLockedBy);
-                if (hr == S_FALSE )
-                {
-                    hr = NETCFG_E_NO_WRITE_LOCK;
-                }
-            }
-        }
-
-        if ( hr == S_OK )
-        {
-            /*
-            * Initialize the INetCfg object.
-            */
-            hr = pnc->Initialize( NULL );
-
-            if ( hr == S_OK )
-            {
-                *ppnc = pnc;
-                pnc->AddRef();
-            }
-            else
-            {
-                /*
-                * Initialize failed, if obtained lock, release it
-                */
-                if ( pncLock )
-                {
-                    pncLock->ReleaseWriteLock();
-                }
-            }
-        }
-
-        vboxNetCfgWinReleaseRef( pncLock );
-        vboxNetCfgWinReleaseRef( pnc );
-    }
-
-    return hr;
-}
-
-/*
-* Get a reference to INetCfg.
-*
-*    pnc           [in] Reference to INetCfg to release.
-*    fHasWriteLock [in] If TRUE, reference was held with write lock.
-*
-* Returns:   S_OK on sucess, otherwise an error code.
-*
-*/
-static HRESULT vboxNetCfgWinReleaseINetCfg (IN INetCfg* pnc,
-                        IN BOOL fHasWriteLock)
-{
-    INetCfgLock    *pncLock = NULL;
-    HRESULT        hr = S_OK;
-
-    /*
-    * Uninitialize INetCfg
-    */
-    hr = pnc->Uninitialize();
-
-    /*
-    * If write lock is present, unlock it
-    */
-    if ( hr == S_OK && fHasWriteLock )
-    {
-
-        /*
-        * Get the locking reference
-        */
-        hr = pnc->QueryInterface( IID_INetCfgLock,
-                                (LPVOID *)&pncLock);
-        if ( hr == S_OK )
-        {
-        hr = pncLock->ReleaseWriteLock();
-        vboxNetCfgWinReleaseRef( pncLock );
-        }
-    }
-
-    vboxNetCfgWinReleaseRef( pnc );
-
-    return hr;
-}
 
 static int vboxNetWinAddComponent(std::list <ComObjPtr <HostNetworkInterface> > * pPist, INetCfgComponent * pncc)
@@ -894,165 +745,4 @@
 
     return rc;
-}
-
-/*
- * Get network component's binding path enumerator reference.
- *
- * Arguments:
- *    pncc           [in]  Network component reference.
- *    dwBindingType  [in]  EBP_ABOVE or EBP_BELOW.
- *    ppencbp        [out] Enumerator reference.
- *
- * Returns:   S_OK on sucess, otherwise an error code.
- */
-
-static HRESULT vboxNetCfgWinGetBindingPathEnum (IN INetCfgComponent *pncc,
-                              IN DWORD dwBindingType,
-                              OUT IEnumNetCfgBindingPath **ppencbp)
-{
-    INetCfgComponentBindings *pnccb = NULL;
-    HRESULT                  hr;
-
-    *ppencbp = NULL;
-
-    /* Get component's binding. */
-    hr = pncc->QueryInterface( IID_INetCfgComponentBindings,
-                               (PVOID *)&pnccb );
-
-    if ( hr == S_OK )
-    {
-
-        /* Get binding path enumerator reference. */
-        hr = pnccb->EnumBindingPaths( dwBindingType,
-                                      ppencbp );
-
-        vboxNetCfgWinReleaseRef( pnccb );
-    }
-
-    return hr;
-}
-
-/*
- * Enumerates the first binding path.
- *
- * Arguments:
- *    pencc      [in]  Binding path enumerator reference.
- *    ppncc      [out] Binding path reference.
- *
- * Returns:   S_OK on sucess, otherwise an error code.
- */
-static HRESULT vboxNetCfgWinGetFirstBindingPath (IN IEnumNetCfgBindingPath *pencbp,
-                               OUT INetCfgBindingPath **ppncbp)
-{
-    ULONG   ulCount;
-    HRESULT hr;
-
-    *ppncbp = NULL;
-
-    pencbp->Reset();
-
-    hr = pencbp->Next( 1,
-                       ppncbp,
-                       &ulCount );
-
-    return hr;
-}
-
-/*
- * Get binding interface enumerator reference.
- *
- * Arguments:
- *    pncbp          [in]  Binding path reference.
- *    ppencbp        [out] Enumerator reference.
- *
- * Returns:   S_OK on sucess, otherwise an error code.
- */
-static HRESULT vboxNetCfgWinGetBindingInterfaceEnum (IN INetCfgBindingPath *pncbp,
-                                   OUT IEnumNetCfgBindingInterface **ppencbi)
-{
-    HRESULT hr;
-
-    *ppencbi = NULL;
-
-    hr = pncbp->EnumBindingInterfaces( ppencbi );
-
-    return hr;
-}
-
-/* Enumerates the first binding interface.
- *
- * Arguments:
- *    pencbi      [in]  Binding interface enumerator reference.
- *    ppncbi      [out] Binding interface reference.
- *
- * Returns:   S_OK on sucess, otherwise an error code.
- */
-static HRESULT vboxNetCfgWinGetFirstBindingInterface (IN IEnumNetCfgBindingInterface *pencbi,
-                                    OUT INetCfgBindingInterface **ppncbi)
-{
-    ULONG   ulCount;
-    HRESULT hr;
-
-    *ppncbi = NULL;
-
-    pencbi->Reset();
-
-    hr = pencbi->Next( 1,
-                       ppncbi,
-                       &ulCount );
-
-    return hr;
-}
-
-/*
- * Enumerate the next binding interface.
- *
- * The function behaves just like vboxNetCfgWinGetFirstBindingInterface if
- * it is called right after vboxNetCfgWinGetBindingInterfaceEnum.
- *
- * Arguments:
- *    pencbi      [in]  Binding interface enumerator reference.
- *    ppncbi      [out] Binding interface reference.
- *
- * Returns:   S_OK on sucess, otherwise an error code.
- */
-static HRESULT vboxNetCfgWinGetNextBindingInterface (IN IEnumNetCfgBindingInterface *pencbi,
-                                   OUT INetCfgBindingInterface **ppncbi)
-{
-    ULONG   ulCount;
-    HRESULT hr;
-
-    *ppncbi = NULL;
-
-    hr = pencbi->Next( 1,
-                       ppncbi,
-                       &ulCount );
-
-    return hr;
-}
-
-/* Enumerate the next binding path.
- * The function behaves just like vboxNetCfgWinGetFirstBindingPath if
- * it is called right after vboxNetCfgWinGetBindingPathEnum.
- *
- * Arguments:
- *    pencbp      [in]  Binding path enumerator reference.
- *    ppncbp      [out] Binding path reference.
- *
- * Returns:   S_OK on sucess, otherwise an error code.
- */
-static HRESULT vboxNetCfgWinGetNextBindingPath (IN IEnumNetCfgBindingPath *pencbp,
-                              OUT INetCfgBindingPath **ppncbp)
-{
-    ULONG   ulCount;
-    HRESULT hr;
-
-    *ppncbp = NULL;
-
-    hr = pencbp->Next( 1,
-                       ppncbp,
-                       &ulCount );
-
-    return hr;
 }
 
Index: /trunk/src/VBox/Main/Makefile.kmk
===================================================================
--- /trunk/src/VBox/Main/Makefile.kmk	(revision 13719)
+++ /trunk/src/VBox/Main/Makefile.kmk	(revision 13720)
@@ -68,7 +68,4 @@
 ifdef VBOX_WITH_NETFLT
  VBOX_MAIN_DEFS += VBOX_WITH_NETFLT
- ifdef VBOX_NETFLT_ONDEMAND_BIND
-  VBoxSVC_DEFS.win += VBOX_NETFLT_ONDEMAND_BIND
- endif
 endif
 ifdef VBOX_WITH_GUEST_PROPS
@@ -319,4 +316,10 @@
 endif
 
+ifdef VBOX_WITH_NETFLT
+ VBoxSVC_LIBS.win += $(PATH_LIB)/WinNetConfig.lib
+ ifdef VBOX_NETFLT_ONDEMAND_BIND
+  VBoxSVC_DEFS.win += VBOX_NETFLT_ONDEMAND_BIND
+ endif
+endif
 VBoxSVC_LDFLAGS.darwin    = -framework IOKit -framework SystemConfiguration
 ifeq ($(KBUILD_TYPE),debug)
