Search code examples
c++windows-cewifiwlanapi

connect to a wifi network with wlantool.exe in Compact 7 failed with 1814 error code


From my command prompt in Compact 7 I try to execute something like this:

wlantool -c -ssid name -auth wpa2psk -encr aes -key mypassword

I get this error: [WLANTOOL] WlanReasonCodeToString() FAILED error: 1814

Same command was working for almost 1 month and suddenly it's returning this error.

  • Network name (SSID): name
  • Encryption: AES
  • Authentication: WPA2-PSK
  • Network key: mypassword

What am I doing wrong in my command promt above? And how do I find out what error 1814 is?

I want to call the command line tool wlantool.exe from a C# program to let the user handle wifi-connections from within my app.

c++ Code of WLANTOOL

DWORD dwFlags = 0;
    BOOL bOverwrite = TRUE;
    DWORD dwReasonCode = WLAN_REASON_CODE_UNKNOWN;
    dwError = WlanSetProfile(*phClientHandle, 
                             &pInterface->InterfaceGuid, 
                             0,
                             bstrXml,
                             NULL,
                             bOverwrite, 
                             NULL, 
                             &dwReasonCode);
    if(ERROR_SUCCESS != dwError)
    {
        WCHAR strMeaning[MAX_PATH];
        DWORD dwEr = ERROR_SUCCESS;

        strMeaning[0] = L'\0';

        dwEr = WlanReasonCodeToString(dwReasonCode,
                                      MAX_PATH,
                                      strMeaning,
                                      NULL);
        if(ERROR_SUCCESS != dwEr )
        {
            PrintMsg(L"WlanReasonCodeToString() FAILED error: %lu",dwEr);
            break;
        }


        PrintMsg(L"WlanSetProfile() FAILED Error: %lu dwReasonCode : %lu Meaning : %s,",
                 dwError,
                 dwReasonCode,
                 strMeaning);
        break;
    }

Solution

  • The issue has happened because WINCE has a limit of 66(not sure is this exact count) number of profiles can be created.When I manually delete some profiles created previously from registry the issue solved.