Configure Wifi Settings using C#

2019-04-02 05:12发布

问题:

How to configure Wifi Settings for a Win Mobile application using C# (compact framework)?

So the deal is:

  • Configure the network (SSID for an hiden AP)
  • WPA authentication with TKIP
  • Force user and password (the end-user won't be prompted for authentication)

回答1:

Take a look at the Smart Device Framework. It has a NetworkInformation namespace that wrap a large amount of the WZC functionality. I know it will do WEP and WPA with TKIP (as well as open). It allows you to pass in the key material, set up most options, etc.

Look specifically at the WirelessZeroConfigNetworkInterface class and it's AddPreferredNetwork method.

Edit: If you're curious what APIs you'd use directly, you'd start here.



回答2:

I'm not sure whether it's possible to programatically change those settings.

The Configuration Service Providers is what you usually use to provision devices with settings like these (also it's used for GPRS settings for example).

What you do is that you create a special CAB-file containing a special _setup.xml which Windows Mobile will use to change the settings.

Read about it here on MSDN (and here for the specific Wifi configuration).

Also note that depending on the device, your cab-file will need to be signed by the device manufacturer (good luck with that...)



回答3:

Alternatively, you could probably utilize the Connection Manager API.



回答4:

The username and password must be set in the registry directly. They're in [HKCU]\Comm\Eapol\<ssid>\Identity and [HKCU]\Comm\Eapol\<ssid>\Password. The username is cleartext, the password is encrypted. Those locations are defined in the platform builder header eapol.h.

-PaulH