Hi,
I am writing an application that scans for the available access points using the NDISUIO calls to the WiFi adapter
on a Windows Mobile 5.0.
The IOCTL for Open Device "IOCTL_NDISUIO_OPEN_DEVICE" failed with the error "0x00000057".
I am not sure what that the Error Code stands for. Which header file are the error codes defined for the NDIS API.
Is it true that NDISUIO allows only one application to access to the Adapter at a time. Since the WZC is active the Native Supplicant gets the access first, leaving my app no access to the adapter.
If the above is true. How do we disable the Native Supplicant on WINCE. Are there any calls that allow to disable the other app using the adapter and get the access to my app.
I have posted my code can anyone point if there is anything missing in it.
================================================== ===========
LPCTSTR pszAdapter = L"HPWIFIDVR1";
HANDLE hDevice = CreateFile(
NDISUIO_DEVICE_NAME, GENERIC_READ,
FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL, OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED,
NULL);
if (hDevice == INVALID_HANDLE_VALUE)
{
DWORD dwError = GetLastError();
printf("Function \"CreateFile\" failed (0x%08x).\n", dwError);
return -2;
}
DWORD dwBytesReturned = 0;
NDISUIO_QUERY_OID NDISUIOQueryOid = {0};
NDISUIOQueryOid.ptcDeviceName = (PTCHAR) pszAdapter;
NDISUIOQueryOid.Oid = OID_GEN_PHYSICAL_MEDIUM;
if (!DeviceIoControl(
hDevice, IOCTL_NDISUIO_QUERY_OID_VALUE,
&NDISUIOQueryOid, sizeof(NDISUIOQueryOid),
&NDISUIOQueryOid, sizeof(NDISUIOQueryOid),
&dwBytesReturned, NULL))
{
DWORD dwError = GetLastError();
CloseHandle(hDevice);
printf("Function \"DeviceIoControl\" (OID_GEN_PHYSICAL_MEDIUM) failed (0x%08x).\n",
dwError);
return -3;
}
if (*((PNDIS_PHYSICAL_MEDIUM) NDISUIOQueryOid.Data) != NdisPhysicalMediumWirelessLan)
{
CloseHandle(hDevice);
printf("Device \"%ls\" is no wireless adapter.\n", pszAdapter );
return -4;
}
if (!DeviceIoControl(
hDevice, IOCTL_NDISUIO_OPEN_DEVICE,
(LPVOID) pszAdapter,
wcslen(pszAdapter),
NULL, 0, &dwBytesReturned, NULL))
{
DWORD dwError = GetLastError();
CloseHandle(hDevice);
printf("Function \"DeviceIoControl\" (IOCTL_NDISUIO_OPEN_DEVICE) failed (0x%08x).\n",
dwError);
return -5;
}
================================================== ===========
EggHeadCafe.com - .NET Developer Portal of Choice
http://www.eggheadcafe.com