CE下重新绑定网卡,下面的代码老是出错,麻烦高手帮我查看一下.谢谢
LPCTSTR NDISUIO_DEVICE_NAME = _T("NDS0:");
WCHAR strAdapterName[] = L"PCI\\RTL81391";
DWORD dwlen = (wcslen(strAdapterName) + 1 ) * sizeof(WCHAR);
BOOL bRet;
LPDWORD dwReturnedBytes = NULL;
HANDLE hAdapter = CreateFile(
NDISUIO_DEVICE_NAME,
GENERIC_READ ¦ GENERIC_WRITE,
FILE_SHARE_READ ¦ FILE_SHARE_WRITE,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL ¦ FILE_FLAG_OVERLAPPED,
INVALID_HANDLE_VALUE);
if(hAdapter==NULL)
{
return false;
}
bRet = DeviceIoControl(
hAdapter,
IOCTL_NDIS_REBIND_ADAPTER,
strAdapterName,
dwlen,
//wcslen((strAdapterName)) * sizeof(WCHAR),
NULL,
0,
dwReturnedBytes,
NULL
);
//bRet在这里的结果却为0.并没有绑定.
CloseHandle(hAdapter);