Exit Windows

D

Doug Bell

Hi,
I am trying to use P/Invoke to shutdown the mobile device and I keep getting
an error:

Can't find an Entry Point 'ExitWindowsEx' in a PInvoke DLL 'coredll.dll'.
I am using:
<Runtime.InteropServices.DllImport("coredll.dll")> _

Public Function ExitWindowsEx(ByVal uFlags As Integer, _

ByVal dwReserved As Integer) As Int32

End Function

Passing
EWX_POWEROFF = &H8 and

SHTDN_REASON_MAJOR_OTHER = &H0



Thanks for any assistance



Doug
 
C

Christian Resma Helle

Sorry Doug, I think it was I who pointed you to coredll. Must have been a
typo. By the way, ExitWindowsEx() is only supported in Windows Mobile 5.0
and later
 
D

Doug Bell

Thanks Peter,
It doesn't error now,
But the emulator doesn't exit either?
I will try deploying it tomorrow.
 
D

Doug Bell

Bugger, I think the Intermecs we are using are running PocketPC, I will
check tomorrow.

Thanks for the other advice.

It does not error now but it does not close the Pocket PC Emulator down, I
assume because the Pocket PC does not support it?

Doug
 
C

Christian Resma Helle

Hi Doug,

To power off a Pocket PC 2003 device you can P/Invoke
SetSystemPowerState(LPCWSTR psState, DWORD StateFlags, DWORD Options) from
coredll.dll

Here are the definitions for the StateFlags parameter:

#define POWER_STATE(f) ((f) & 0xFFFF0000) // power state
mask
#define POWER_STATE_ON (DWORD)(0x00010000) // on state
#define POWER_STATE_OFF (DWORD)(0x00020000) // no power,
full off
#define POWER_STATE_CRITICAL (DWORD)(0x00040000) // critical off
#define POWER_STATE_BOOT (DWORD)(0x00080000) // boot state
#define POWER_STATE_IDLE (DWORD)(0x00100000) // idle state
#define POWER_STATE_SUSPEND (DWORD)(0x00200000) // suspend state
#define POWER_STATE_RESET (DWORD)(0x00800000) // reset state
 
G

Guest

You shouldn't be testing any kind of power-related stuff, including
shutdown, on the emulator. It likely doesn't work at all.


--

Chris Tacke, Embedded MVP
OpenNETCF Consulting
Managed Code in an Embedded World
www.OpenNETCF.com
 
D

Doug Bell

Thanks Christian

Christian Resma Helle said:
Hi Doug,

To power off a Pocket PC 2003 device you can P/Invoke
SetSystemPowerState(LPCWSTR psState, DWORD StateFlags, DWORD Options) from
coredll.dll

Here are the definitions for the StateFlags parameter:

#define POWER_STATE(f) ((f) & 0xFFFF0000) // power state
mask
#define POWER_STATE_ON (DWORD)(0x00010000) // on state
#define POWER_STATE_OFF (DWORD)(0x00020000) // no power,
full off
#define POWER_STATE_CRITICAL (DWORD)(0x00040000) // critical off
#define POWER_STATE_BOOT (DWORD)(0x00080000) // boot state
#define POWER_STATE_IDLE (DWORD)(0x00100000) // idle state
#define POWER_STATE_SUSPEND (DWORD)(0x00200000) // suspend state
#define POWER_STATE_RESET (DWORD)(0x00800000) // reset state
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top