Enable and disable WiFi in Mobile 6

Source: Internet
Author: User

 

Note: If the following header file and library file are added to the program, the system still prompts that the file cannot be found or the external reference is incorrect, search for the added lib file and header file in the wm614 \ public directory, and copy them to: D: \ Program Files \ Windows Mobile 6 SDK \ pocketpc \ include \ armv4i \ and D: \ Program Files \ Windows Mobile 6 SDK \ pocketpc \ Lib \ armv4i \ directory.

 

NAdd header files and library files

# Include <wrlspwr. h>

# Pragma comment (Lib, "ossvcs. lib ")

NEnable and disable WiFi

ØClose

RDD * devicelist = NULL;

Getwirelessdevices (& devicelist, wireless_no_phone );

Changeradiostate (devicelist, 0, power_post_save );

Freedevicelist (pdevice );

ØOpen

RDD * devicelist = NULL;

Getwirelessdevices (& devicelist, wireless_no_phone );

Changeradiostate (devicelist, 1, power_post_save );

Freedevicelist (pdevice );

Since the implementation is relatively simple, let's look at the getwirelessdevices and changeradiostate functions. In fact, this is a simple translation of the above descriptions in Mobile 6 documents.

ØGetwirelessdevices

LFunction prototype

Hresult getwirelessdevices (

RDD **Pdevices,

DWORDDwflags

);

LParameter meaning

Pdevices: The address pointing to the device pointer in the linked list. If it succeeds, it will be a node of the RDD structure type.

Dwflags: Indicates which device to set or whether to set the desired status. The following are possible values and descriptions:

Flag

Value

Description

Wireless_get_desired

1

Returns the expected device status of the expected member variable in the RDD structure. This is what users want when wireless signals are enabled. For example, if you set the phone number in the Power Manager but disable the signal, the variable value is still 1. however, the actual dwstate is still 0. if you are only interested in the current status of the device, do not pass this parameter and do not desire to return meaningful values in the expected member variables.

Wireless_no_power_man

2

Remove wireless devices with power management from the list

Wireless_no_phone

4

No phone device in the returned list

 

LReturn Value

Value

Description

S_ OK

The wireless device status is successfully set.

E_fail

Failed to specify

S_false

Insufficient memory

ØChangeradiostate

LFunction prototype

HRESULT ChangeRadioState(
  RDD *pDev,
  DWORD dwState
  SAVEACTION sa
);

LParameter meaning

Pdev: Specify devices in the linked list of wireless devices

Dwstate: Specifies the power status to be set. The following values are possible:

Status

Value

Description

Off

0

Power off wireless devices

On

1

Power on wireless devices

Discoverable

2

Set wireless devices to be discovered by other Bluetooth devices

 

SA: Specifies how the desired status is updated in the registry. The following enumerated values are possible:

typedef enum _SAVEACTION {
    POWER_DONT_SAVE = 0,
    POWER_PRE_SAVE,
    POWER_POST_SAVE,
} SAVEACTION;

Value

Description

Power_dont_save

When the RF status changes, it will not be updated

Power_pre_save

Regardless of how the RF status changes, the preservation of the RF status prevails over the change of the RF status.

Power_post_save

No matter how the RF status changes, the new status is saved as the user-specified status.

 

LReturn Value

Value

Description

S_ OK

RF status set successfully

E_fail

RF status not changed

S_false

The RF status has been set to the desired status

 

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.