Psion WorkAbout Pro with Windows CE .NET 4.2
Dealer gave me PowerAPIOn.exe and PowerAPIOff.exe to turn on/off tag reader,
but I want to do it programmatically and do the same with WiFi and Bluetooth
as I can do from Control Panel ("Network and dialup connections" and
"Power").
Googling I've found that I should:
- search all devices in
HKEY_LOCAL_MACHINE / System / CurrentControlSet / Control / POWER /
State / {98C5250D-C29A-4985-AE5F-AFE5367E5006} / <DEVICE_NAME>
I've found no devices under POWER.
In Control Panel I've found that I've a Cambridge Silicon Bluetooth chip.
Under HKEY_LOCAL_MACHINE/Comm I've found:
- an unknown CF8385PN1 device
- an Agere WLAGS46B1 WiFi compact flash
- use "SetDevicePower" but I don't know <DEVICE_NAMEand Microsoft
discourages application developers from calling this function:
http://msdn2.microsoft.com/en-us/library/ms889607.aspx
- use "SetPowerRequirement" in this way:
[DllImport("coredll.dll", SetLastError = true)]
private static extern IntPtr SetPowerRequirement
(
string pvDevice,
CEDEVICE_POWER_STATE DeviceState,
uint DeviceFlags,
IntPtr pvSystemState,
uint StateFlags
);
...
string deviceName = ...;
CEDEVICE_POWER_STATE deviceState = ...;
uint devFlags = POWER_NAME | POWER_FORCE;
SetPowerRequirement(deviceName, deviceState, devFlags, IntPtr.Zero, 0);
MSDN says "DeviceFlags = Bitwise-or of the following flags POWER_NAME,
POWER_FORCE".
This mean Bitwise-or of all the flags or Bitwise-or of the needed ones?
MSDN says "pvDevice Must be a valid LPWSTR device name, for example,
"COM1:". The actual meaning is determined by the DeviceFlags parameter."
As mentioned above for "SetDevicePower" I don't know <DEVICE_NAME>.
In which way DeviceFLags modify the meaning???
MSDN says "POWER_NAME specifies the name of the device whose power should
be maintained at or above the DeviceState level."
I've found in Pm.h that POWER_NAME is a DWORD whose value is 1:
how can it specify a name???
Maybe MSDN means that if I use POWER_NAME will be used the name of the
device that is calling SetPowerRequirement?
If I import the dll why I have to define CEDEVICE_POWER_STATE again in
C#???