In Windows Mobile, turn on/off wifi.

Source: Internet
Author: User

The yonsm brother wrote "Windows Mobile switches WiFi"Code.
Original address: http://www.yonsm.net/read.php? 412

The test on my machine (586 W 6.1) was ineffective. After research, I found that yonsm'sAlgorithmNot common, at least on my machine.
The problem is to get the name of the WiFi adapter.

After searching the registry, I finally found a solution.
HKEY_LOCAL_MACHINE/system/CurrentControlSet/control/power/
State/{98c5250d-c29a-4985-ae5f-afe5367e5006 }\< device_name>

<Device_name> indicates the name of the adapter.
Note: {98c5250d-c29a-4985-ae5f-afe5425e5006 }\< device_name> indicates the key name, not the parent path of the child.

Pass the key name directly to the pvdevice parameter of setdevicepower.

Appendix: C # implementation code!

 

String [] Snames =   Null ;
Registrykey keywlan =   Null ;
Try
{
Keywlan=Registry. localmachine. opensubkey (@"System \ CurrentControlSet \ Control \ power \ state");
Snames=Keywlan. getvaluenames ();
}
Catch   {}
Finally
{
If(Keywlan! = Null) Keywlan. Close ();
}

Foreach ( String WL In Snames)
{
If (WL. startswith ( " {98c5250d-c29a-4985-ae5f-afe5425e5006 }\\ " ))
{
// Power_name = 0x00000001
Setdevicepower ( WL , Zero X 00000001 , Open ? Devicepowerstate. D0: devicepowerstate. D4 );
Break ;
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.