Hello,
I look for a way to change the network binding programmaticaly-
my problem seems to be the same, as jim2005's in the thread:
"How to programmatically set binding order of NDIS miniport adapter on
install?".
So, I took a look at BindView example in WinDDK and what
I do is:
I acquire a write lock using
INetCfgLock->AcquireWriteLock
I enumarate all the components
INetCfgClass->EnumComponents,
and I search for the component I want to put on the top
of the list.
Then I enumarate all the binding paths for the component using:
INetCfgComponentBindings->EnumBindingPaths
For each of the binding path I try to call
INetCfgComponentBindings->MoveBefore
with the second argument = NULL.
However, it gives me an error:
-2147180508
And this is where I stuck :-(
As I'm not very experienced with C++ programming
(I come from the .NET world) I have no clue
where I should go next.
Can anyone give me any suggestion what may be the cause
for the error?
Has anyone ever manage to make a good use of MoveBefore
(or MoveAfter) and would share a snippet of code?
I'll be very grateful - thanks in advance.

Marcin Pytel

--

Re: Network bindings -> MoveBefore - error by Marcin

Marcin
Wed Sep 07 07:43:56 CDT 2005

Hello again,
I went through the code again, and
"mea culpa" -> in fact, the write lock wasn't granted
and thus the error (it's in fact NETCFG_E_NO_WRITE_LOCK).
However, after fixing this I keep receiving
E_INVALIDARG error on calling MoveBefore with
the NULL as the second parameter.
Any ideas?
Thanks,
Marcin Pytel

--

U¿ytkownik "Marcin P" <protected(NOSPAM)@poczta.onet.pl> napisa³ w
wiadomo¶ci news:%23MQHYo5sFHA.1448@TK2MSFTNGP10.phx.gbl...
> Hello,
> I look for a way to change the network binding programmaticaly-
> my problem seems to be the same, as jim2005's in the thread:
> "How to programmatically set binding order of NDIS miniport adapter on
> install?".
> So, I took a look at BindView example in WinDDK and what
> I do is:
> I acquire a write lock using
> INetCfgLock->AcquireWriteLock
> I enumarate all the components
> INetCfgClass->EnumComponents,
> and I search for the component I want to put on the top
> of the list.
> Then I enumarate all the binding paths for the component using:
> INetCfgComponentBindings->EnumBindingPaths
> For each of the binding path I try to call
> INetCfgComponentBindings->MoveBefore
> with the second argument = NULL.
> However, it gives me an error:
> -2147180508
> And this is where I stuck :-(
> As I'm not very experienced with C++ programming
> (I come from the .NET world) I have no clue
> where I should go next.
> Can anyone give me any suggestion what may be the cause
> for the error?
> Has anyone ever manage to make a good use of MoveBefore
> (or MoveAfter) and would share a snippet of code?
> I'll be very grateful - thanks in advance.
>
> Marcin Pytel
>
> --
>
>
>



Re: Network bindings -> MoveBefore - error by Stephan

Stephan
Fri Sep 09 04:43:50 CDT 2005

I can only guess your "source item" parameter is incorrect.

See also

"How to change the binding order of network adapters in Windows XP and
in Windows 2000"
http://support.microsoft.com/?kbid=894564

Stephan
---
Marcin P (NOSPAM) wrote:
> Hello again,
> I went through the code again, and
> "mea culpa" -> in fact, the write lock wasn't granted
> and thus the error (it's in fact NETCFG_E_NO_WRITE_LOCK).
> However, after fixing this I keep receiving
> E_INVALIDARG error on calling MoveBefore with
> the NULL as the second parameter.
> Any ideas?
> Thanks,
> Marcin Pytel


Re: Network bindings -> MoveBefore - error by Gucio

Gucio
Fri Sep 09 05:11:35 CDT 2005


> "How to change the binding order of network adapters in Windows XP and
> in Windows 2000"
> http://support.microsoft.com/?kbid=894564

We try doing that as it's described in article above, but it doesn't works
!!!

Marcin has a problem strictly with NETCFG_E_NO_WRITE_LOCK.

He try sample which is described under "The Bindview sample in the Microsoft
Windows Driver Development Kit" section of this article.


We must change it on many computers and we want to avoid manulal
reconfiguration order of the connections.

Regards, Gucio.



Re: Network bindings -> MoveBefore - error by Stephan

Stephan
Fri Sep 09 09:13:42 CDT 2005

Gucio (NOSPAM) wrote:
> > "How to change the binding order of network adapters in Windows XP and
> > in Windows 2000"
> > http://support.microsoft.com/?kbid=894564
>
> We try doing that as it's described in article above, but it doesn't works
> !!!

Do you have the latest DDK? See

http://www.microsoft.com/ddk

Does the BindView sample allow you to change the order of binding paths
(manually)? And does that work? If yes, what are you doing differently?

Stephan


Re: Network bindings -> MoveBefore - error by Raj

Raj
Thu Sep 29 14:19:35 CDT 2005

Marcin P (NOSPAM) wrote:
> Hello,
> I look for a way to change the network binding programmaticaly-
> my problem seems to be the same, as jim2005's in the thread:
> "How to programmatically set binding order of NDIS miniport adapter on
> install?".
> So, I took a look at BindView example in WinDDK and what
> I do is:
> I acquire a write lock using
> INetCfgLock->AcquireWriteLock
> I enumarate all the components
> INetCfgClass->EnumComponents,
> and I search for the component I want to put on the top
> of the list.
> Then I enumarate all the binding paths for the component using:
> INetCfgComponentBindings->EnumBindingPaths
> For each of the binding path I try to call
> INetCfgComponentBindings->MoveBefore
> with the second argument = NULL.
> However, it gives me an error:
> -2147180508
> And this is where I stuck :-(
> As I'm not very experienced with C++ programming
> (I come from the .NET world) I have no clue
> where I should go next.
> Can anyone give me any suggestion what may be the cause
> for the error?
> Has anyone ever manage to make a good use of MoveBefore
> (or MoveAfter) and would share a snippet of code?
> I'll be very grateful - thanks in advance.
>
> Marcin Pytel
>
> --

I am also running into the same issue of NETCFG_E_NO_WRITE_LOCK.

I have used the same exact above procedure from bindview sample to
enumerate the bindings and use Move Before to change the order.

I thought that code is able to acquire a write lock because if I run
the program while Network Connections> Advanced > Advanced Connections
is open it complains that it is not able to acquire a write lock.

But when I call MoveBefore it complains about write
lock(NETCFG_E_NO_WRITE_LOCK).

Any clue on how to obtain the write lock?