Wireless User Interface APIs

Windows 8, Windows Server 2012, and later include a new Connection Manager feature that allows users to easily connect to the Internet and to other networks (work and home networks, for example). This new Connection Manager feature replaces the older Connect to a network and Manage Wireless Networks user interfaces included with older versions of Windows for managing Native Wifi connections.

On Windows 7, Windows Server 2008, and Windows Vista, there are a number of user interfaces (UIs) used to connect to or configure a wireless network. These UIs can be started in an application using Native Wifi and Windows Shell functions. These UIs are not available on Windows 8, Windows Server 2012, and later.

Windows XP with SP3 and Wireless LAN API for Windows XP with SP2: You cannot start any UI used to connect to or configure a wireless network in an application programmatically.

Connect to a network

On Windows 8, Windows Server 2012, Windows 7, Windows Server 2008, and Windows Vista, the Connect to a network wizard can be used to establish a connection to a wireless network. You can use the ShellExecute function to start the Connect to a network wizard.

The following code shows a ShellExecute call that starts the Connect to a network wizard.

#ifndef UNICODE
#define UNICODE
#endif

#include <windows.h>
#include <shellapi.h>

// Need to link with shell32.lib
#pragma comment(lib, "shell32.lib")

void wmain()
{
   ShellExecute(
      NULL, 
      L"open", 
      L"shell:::{21EC2020-3AEA-1069-A2DD-08002B30309D}\\::{38a98528-6cbf-4ca9-8dc0-b1e1d10f7b1b}",
      NULL,
      NULL,
      SW_SHOWNORMAL);
}

Manage Wireless Networks

On Windows 7, Windows Server 2008, and Windows Vista, the Manage Wireless Networks Control Panel item is used to manage wireless network profiles. The ShellExecute function can also be used to start the Manage Wireless Networks item. The path to use when calling ShellExecute on Windows 7 and Windows Vista is the following:

shell:::{26EE0668-A00A-44D7-9371-BEB064C98683}\3\::{1fa9085f-25a2-489b-85d4-86326eedcd87} .

The following sample code shows how to use ShellExecute to start the Managed Wireless Networks wizard from an application.

#ifndef UNICODE
#define UNICODE
#endif

#include <windows.h>
#include <shellapi.h>
#include <stdio.h>

// Need to link with shell32.lib
#pragma comment(lib, "shell32.lib")

int wmain()
{

    //-----------------------------------------
    // Declare and initialize variables
    HINSTANCE nResult;

    PCWSTR lpOperation = L"open";    
    PCWSTR lpFile= 
        L"shell:::{26EE0668-A00A-44D7-9371-BEB064C98683}\\3\\::{1fa9085f-25a2-489b-85d4-86326eedcd87}";

    nResult = ShellExecute(
        NULL,   // Hwnd
        lpOperation, // do not request elevation unless needed
        lpFile,
        NULL, // no parameters 
        NULL, // use current working directory 
        SW_SHOWNORMAL);

    if((int)nResult == SE_ERR_ACCESSDENIED)
    {
        wprintf(L"ShellExecute returned access denied\n");
        wprintf(L"  Executing the ShellExecute command elevated\n"); 

        nResult = ShellExecute(
            NULL,
            L"runas", // Trick for requesting elevation
            lpFile,
            NULL, // no parameters 
            NULL, // use current working directory 
            SW_HIDE);
    }

    if ( (int) nResult < 32) {
        wprintf(L" ShellExecute failed with error %d\n", (int) nResult);
        return 1;
    }    
    else {    
        wprintf(L" ShellExecute succeeded and returned value %d\n", (int) nResult);
        return 0;
    }
}

Advanced Settings for Wireless Network Profiles

Windows Vista and later include an advanced user interface that is used to view and edit advanced settings of a wireless network profile. You can start this advanced UI by calling the WlanUIEditProfile function.

Using Native Wifi

Wireless profile samples

ShellExecute

WlanUIEditProfile