Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 633823
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T20:13:40+00:00 2026-05-13T20:13:40+00:00

I have been working on this for a few days and this is doing

  • 0

I have been working on this for a few days and this is doing my head in:

Our application is built using the .NET Compact Framework 2.0 and running on Windows Mobile 5 & 6 devices.
We can set the WLAN connection of the device programmatically using the Wireless Zero Config functions (described here: msdn.microsoft.com/en-us/library/ms894771.aspx), most notably the WZCSetInterface function which we pinvoke from our application. This works fine for WEP and WPA-PSK connections.

In a recent effort to add support for WPA2 networks we decided to modify the code. We have successfully added support for WPA2 which uses a certificate for the 802.1x authentication by setting the correct registry settings before calling WZCSetInterface.
Now we want to do the same for WPA2 using PEAP (MS-CHAPv2) authentication. When manually creating such a connection in Windows Mobile the user will be prompted to enter the domain/user/password details. In our application we will have those details stored locally and want to do this all programmatically without any user intervention.

So I thought going along the same route as the certificate authentication, setting the correct registry entries before calling WZCSetInterface.

The registry settings we set are:
\HKCU\Comm\EAP\Config\[ssid name]

  • Enable8021x = 1 (DWORD)
  • LastAuthSuccessful = 1 (DWORD)
  • EapTypeId = 25 (DWORD)
  • Identity = “domain\username” (string)
  • Password = binary blob containing the password that is encrypted using the
    CryptProtectData function (described here: msdn.microsoft.com/en-us/library/ms938309.aspx)

But when these settings are set and I call WZCSetInterface with the correct parameters, it still prompts me with the User Logon dialog asking for the domain/username/password.

Has anyone got an idea what I need to do to prevent the password dialog from appearing and connect straight away with the settings stored in the registry?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T20:13:41+00:00Added an answer on May 13, 2026 at 8:13 pm

    After some more investigation I eventually gave up with the registry settings. It seems that the key to a successful connection is the Password value in HKCU\Comm\EAP\Config[SSID]. But because CryptProtectData uses an undocumented entropy value (for obvious security reasons) to encrypt the password, it seems impossible to recreate a valid entry in the registry programmatically.

    I then went with the second best solution, catching the User Logon dialog after calling WZCSetInterface and enter the required fields in there:

    bool enteredPeapCred = false;
    DateTime timePeapCredStarted = DateTime.Now.AddSeconds(10);
    
    // wait for PEAP credentials window to appear (max. wait for 10 seconds)
    while (!enteredPeapCred && timePeapCredStarted >= DateTime.Now)
    {
      IntPtr hwndLogon = Win32.FindWindow(null, "User Logon");
    
      if (hwndLogon != IntPtr.Zero)
      {
        // move User Logon window offscreen to prevent screen flicker in app
        Win32.MoveWindow(hwndLogon, -600, 0, 320, 480, true);                               
    
        // "Network Log On" label   
        IntPtr hwndCtrl1 = Win32.GetWindow(hwndLogon, Win32.GW_CHILD); 
        // "Enter network info..." label
        IntPtr hwndCtrl2 = Win32.GetWindow(hwndCtrl1, Win32.GW_HWNDNEXT); 
        // "User name:" label
        IntPtr hwndCtrl3 = Win32.GetWindow(hwndCtrl2, Win32.GW_HWNDNEXT); 
        // username textbox
        IntPtr hwndCtrl4 = Win32.GetWindow(hwndCtrl3, Win32.GW_HWNDNEXT);
        // "Password:" label 
            IntPtr hwndCtrl5 = Win32.GetWindow(hwndCtrl4, Win32.GW_HWNDNEXT);
        // password textbox 
        IntPtr hwndCtrl6 = Win32.GetWindow(hwndCtrl5, Win32.GW_HWNDNEXT); 
        // enter password into textbox
        StringBuilder sbPassword = new StringBuilder();
        sbPassword.Append(eapPassword);
        Win32.SetWindowText(hwndCtrl6, sbPassword);
        // "Domain:" label
        IntPtr hwndCtrl7 = Win32.GetWindow(hwndCtrl6, Win32.GW_HWNDNEXT); 
        // domain textbox
        IntPtr hwndCtrl8 = Win32.GetWindow(hwndCtrl7, Win32.GW_HWNDNEXT);
        // "Save password" checkbox 
        IntPtr hwndCtrl9 = Win32.GetWindow(hwndCtrl8, Win32.GW_HWNDNEXT); 
        // send BST_CHECKED message to set checkbox
        Win32.SendMessage(hwndCtrl9, Win32.BM_SETCHECK, Win32.BST_CHECKED, 0);                                
    
        // send WM_COMMAND with left softkey to submit user dialog
        IntPtr hwndMenu = Win32.SHFindMenuBar(hwndLogon);
        Win32.SendMessage(hwndLogon, Win32.WM_COMMAND, 0x2F87, hwndMenu.ToInt32());
    
        enteredPeapCred = true;                                
      }
    }
    

    Note that I’m only setting the password field, because the username and domain fields are pre-populated with the information already stored in the registry (the Identity value mentioned in my original question).

    This works well enough, as it creates the WLAN connection using the PEAP credentials. And by moving User Logon dialog offscreen as soon as it’s found, this all happens invisibly to our application’s user (our app runs in kiosk mode).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been working with Visual Studio (WinForm and ASP.NET applications using mostly C#)
I have been working now for few days on a small C program which
I have been working on this for the greater part of the day and
I have been working on Flex for last couple of months and as this
I have this classic ASP site which has been working fine until we updated
I have been working as a native C++ programmer for last few years. Now
Over the past few days I have been trying to create/run a project in
I have been using Shawn Wildermuths example and it has been working fine no
I have been working on a web services related project for about the last
I have been working with a string[] array in C# that gets returned from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.