次の方法で共有


Network UI Sample Application Ethman (Compact 2013)

10/26/2015

This sample shows you how to display an icon in the notification area that indicates network information, such as IP address and wireless network availability, and provides a basic configuration dialog box for 802.11 adapters if no previous configuration is available.

The source code is located in %_WINCEROOT%\Public\Common\Oak\Drivers\Netsamp\Ethman.

Prerequisites

  • Windows Embedded Compact 2013
  • Microsoft Visual Studio 2013 or Microsoft Visual Studio 2015
  • Network UI Sample Application Connmc (SYSGEN_CONNMC)
  • At least one wired or wireless network controller with the proper NDIS miniport driver

Using the Sample

To build and run the sample using an in-proc server

  1. Create an OS design in Platform Builder.

  2. Include the Network User Interface catalog item (SYSGEN_CONNMC) in the OS design.

    For more information, see Network User Interface Catalog Items and Sysgen Variables.

  3. Build the OS design into a run-time image.

  4. Download the run-time image onto the device.

How the Sample Works

Click the icon in the notification area of the taskbar to start Ethman from the sample shell. Ethman interacts with the automatic configuration subsystem, and uses the wlanapi interface to retrieve and set 802.11 parameters, such as signal strength and a visible Service Set Identifier (SSID) list.

It uses the Network Driver Interface Specification (NDIS) User-mode I/O (NDISUIO) interface to register for notifications of adapter insertion or removal.

It loads a wrapper into the user process to communicate with the LAN driver. The wlanapi interface is exposed in the header file wlanapi.h.

The following table shows the Ethman functions that are exported by NetUI. A sample of these functions and their return values are contained in Ethman.h in the %_WINCEROOT%\Public\Common\Oak\Drivers\Netsamp\Ethman directory.

Function

Description

Parameters

AddNetUISystrayIcon

Adds an icon to the system tray for a network adapter.

  • ptcDeviceName is a unique device name.
  • fWireless indicates the adapter type. TRUE indicates a wireless adapter. FALSE indicates a wired adapter.
  • phWnd is a pointer to the handle of the window associated with the system tray icon.

RemoveNetUISystrayIcon

Removes an icon from the tray for a network adapter.

  • ptcDeviceName is a unique device name to remove.

IsPropSheetDialogMessage

Netui currently maintains a list that associates a property sheet with each of the HWNDs returned in AddNetUISystrayIcon. Because ethman actually has the message pump, it is necessary to provide this function which should call into PropSheet_IsDialogMessage and return this result.

  • hWnd is a window handle.
  • pMsg is a pointer to the window message.

ClosePropSheetDialogIfReady

For a modeless property sheet, the message pump must call into PropSheet_GetCurrentPageHwnd to determine if the property sheet should be destroyed. This function must look up the property sheet of the associated hWnd and destroy the window if necessary.

  • hWnd is window handle.

UpdateConnectionStatus

Update the status of a given tray icon to either by connected or not connected.

  • ptcDeviceName is a device name.
  • fConnection indicates the new status of the icon. TRUE indicates connected FALSE indicates not connected.

Note

When Ethman adds a wireless adapter, a dialog box appears that offers options for the user to set the wireless properties. These properties are then set in the wzcuip.c file for use by the operating system.

The following code example shows the network UI code that is used by ethman.dll to populate its simple wireless dialog box. In this example, rdBSSIDList is used to show visible networks and rdStSSIDList is used to show preferred networks.

HRESULT RefreshWirelessInfo(HWND hwndDlg)
{
       HRESULT             hr            = S_OK;
       DWORD         dwError             = ERROR_SUCCESS;
       SystrayIcon       *pSysIcon    = NULL;
 
       // Get the notification icon for the given window
       hr = GetDeviceSystrayIcon(hwndDlg, &pSysIcon);
       if(FAILED(hr) || !pSysIcon)
       {
              DEBUGMSG(ZONE_ERROR, (TEXT("NETUIQC: Error getting systray icon struct")));
              goto exit;
       }
 
       // If the zero config data has already been deleted, then do not delete it.
       // This should not ever get called, but it is best to be certain.
       // If it does get called, the refresh thread will exit quietly and
       // the notification should resume the next time around.
       if(pSysIcon->WLanInfo.IntfEntry.bInitialized == FALSE)
       {
              hr = E_FAIL;
              goto exit;
       }
       
       pfnWZCDeleteIntfObj(&pSysIcon->WLanInfo.IntfEntry);
 
       pSysIcon->WLanInfo.IntfEntry.wszGuid = pSysIcon->ptcDeviceName;
 
       // GetWireless Info
       if ((dwError = pfnWZCQueryInterface(
                    NULL,
                    INTF_ALL,
                    &pSysIcon->WLanInfo.IntfEntry,
                    &pSysIcon->WLanInfo.dwOIDFlags)) != ERROR_SUCCESS) 
       {
               DEBUGMSG(ZONE_ERROR,(TEXT("NETUIQC: WZCQueryInterface failed 0x%X\r\n"),dwError));
               hr = E_FAIL;
               goto exit;
       }      
 
       FillVisibleList(&pSysIcon->WLanInfo,(PWZC_802_11_CONFIG_LIST)pSysIcon->WLanInfo.IntfEntry.rdBSSIDList.pData);
       FillPreferredList(&pSysIcon->WLanInfo,(PWZC_802_11_CONFIG_LIST)pSysIcon->WLanInfo.IntfEntry.rdStSSIDList.pData);
       FillCurrentConfig(&pSysIcon->WLanInfo,&pSysIcon->WLanInfo.IntfEntry);
       
exit:
       
       return hr;
       
} // RefreshWirelessInfo

See Also

Tasks

Network UI Sample Application Connmc
Network UI Sample Application Rnaapp

Concepts

Network User Interface Catalog Items and Sysgen Variables

Other Resources

Network User Interface