Problems using "IOCTL_NDISUIO_OPEN_DEVICE" on WinCE

Discussion in 'Wireless Networking' started by Vijay Kumar P, Jun 26, 2007.

  1. 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
     
    Vijay Kumar P, Jun 26, 2007
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?QXBhY2hldGE=?=

    WinCE 4.2 802.11 Association problems

    =?Utf-8?B?QXBhY2hldGE=?=, Jul 27, 2004, in forum: Wireless Networking
    Replies:
    0
    Views:
    1,225
    =?Utf-8?B?QXBhY2hldGE=?=
    Jul 27, 2004
  2. Tosh
    Replies:
    1
    Views:
    5,908
    Richard Sanderson
    Jan 31, 2004
  3. geraldh

    WinCE NDIS Protocol - Power Transitions?

    geraldh, Jun 22, 2006, in forum: Wireless Networking
    Replies:
    0
    Views:
    1,096
    geraldh
    Jun 22, 2006
  4. =?Utf-8?B?VG9ueQ==?=

    wireless router with xp/smartphone modem and wince networking/ics

    =?Utf-8?B?VG9ueQ==?=, Mar 18, 2007, in forum: Wireless Networking
    Replies:
    6
    Views:
    891
    =?Utf-8?B?VG9ueQ==?=
    Mar 28, 2007
  5. Le.Wang
    Replies:
    0
    Views:
    967
    Le.Wang
    Apr 14, 2011
Loading...

Share This Page