PC Review


Reply
Thread Tools Rating: Thread Rating: 1 votes, 1.00 average.

Change binding order of network adapters in Windows XP

 
 
=?Utf-8?B?SnVhbiBNb3JhdG8=?=
Guest
Posts: n/a
 
      28th Apr 2006
Hello,
I am trying to look for a way to change the binding order of network
adapters in Windows XP programmaticaly.
I'm already checked out http://support.microsoft.com/kb/894564/en-us, and
what I do is
1 - acquire a write lock using
INetCfgLock->AcquireWriteLock
2 - enumerate all the components
INetCfgClass->EnumComponents
3 - search for the component I want to put on the top of the list.
4 - enumerate all the binding paths for the component
INetCfgComponentBindings->EnumBindingPaths
5 - for each binding path I try to call
INetCfgComponentBindings->MoveBefore
with NULL as the second argument.
but it gives me E_INVALIDARG
And here is where I stuck :-(

I have the latest Windows XP DDK downloaded from MSDN.

Can anyone give me any suggestion what may be the cause for the error?
May be the null as second parameter?
What do i do if I can not pass null as the second argument to MoveBefore?

Next is my code. Thanks in advance.

HRESULT NetCfgAPI::SetPrimaryNetworkAdapter(INetCfg* pNetCfg,LPWSTR
adapterName)
{
HRESULT hr= NULL;
LPWSTR displayName = NULL;
INetCfgClass* pNetCfgClass = NULL;
INetCfgComponent* pNetCfgComp = NULL;
INetCfgBindingPath* pNetCfgBind = NULL;
IEnumNetCfgComponent* pEnumComp = NULL;
IEnumNetCfgBindingPath* pEnumBind= NULL;
NetCfgComponentBindings* pNetCfgCompBind = NULL;

hr = this->HrGetComponentEnum(pNetCfg, &GUID_DEVCLASS_NET, &pEnumComp,
&pNetCfgClass);
if (hr==S_OK)
{
hr = this->HrGetFirstComponent(pEnumComp, &pNetCfgComp);
while (hr==S_OK)
{
hr = pNetCfgComp->GetDisplayName(&displayName);


if (wcscmp(displayName, adapterName)==0)
{

hr = pNetCfgComp->QueryInterface( IID_INetCfgComponentBindings, (PVOID
*)&pNetCfgCompBind );
if ( hr == S_OK )
{
// PATHS
LPWSTR path;
hr = this->HrGetBindingPathEnum(pNetCfgComp,EBP_BELOW,&pEnumBind);
if (hr==S_OK)
{
hr = this->HrGetFirstBindingPath(pEnumBind, &pNetCfgBind);
while (hr==S_OK)
{
hr = pNetCfgBind->GetPathToken(&path);
hr = pNetCfgCompBind->MoveBefore(pNetCfgBind,NULL); // Move adapter
binding to Primary
hr = this->HrGetNextBindingPath(pEnumBind, &pNetCfgBind);
}
}

}
}
hr = this->HrGetNextComponent(pEnumComp, &pNetCfgComp);
}
}
return hr;
}

 
Reply With Quote
 
 
 
 
New Member
Join Date: Apr 2007
Posts: 1
 
      30th Apr 2007
I have the same problem.
Who knows the decision of a problem?
 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to change the binding order of network providers =?Utf-8?B?YnVsa2xvZGQ=?= Windows Vista Networking 6 11th Jun 2008 09:51 PM
network adapters binding amir Microsoft C# .NET 0 30th Jul 2007 10:21 AM
Network Binding Order =?Utf-8?B?TnlxdWlzdA==?= Windows XP Embedded 4 1st May 2005 08:34 PM
Controlling DNS query order in multiple network adapters Aaron Seet Microsoft Windows 2000 DNS 4 10th Mar 2004 11:23 AM
Controlling DNS query order in multiple network adapters Aaron Seet Windows XP Networking 1 2nd Mar 2004 01:24 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:13 AM.