GetDevicePower() problems

Joined
May 14, 2007
Messages
1
Reaction score
0
I'm currently working on a pocket pc C# application to grab device power information, but whenever I try to call GetDevicePower I keep getting a return value of 2 (ERROR_FILE_NOT_FOUND I believe). I think it's because the device name isn't recognized but I can't figure out why for the life of me. Here's some of the code I'm using.

Code:
     [DllImport("coredll.dll", SetLastError = true)]
     public static extern int GetDevicePower(
     string pvDevice,int dwDeviceFlags, ref CE_DEVICE_POWER DeviceState);
     
 public const int POWER_NAME  = 0x00000001;
     public enum CE_DEVICE_POWER
     {
     	  PwrDeviceUnspecified = -1,
     	  D0 = 0,
     	  D1,
     	  D2,
     	  D3,
     	  D4,
     	  PwrDeviceMaximum
     };
     
     string DeviceName = txtDeviceName.Text;
     CE_DEVICE_POWER state = new CE_DEVICE_POWER();
     int result = GetDevicePower(DeviceName, POWER_NAME, ref state);

No matter what I try, I always seem to get a return value of 2. For DeviceName I've tried some of the following: "WAV1:", "WAV1", and I've tried a few device classes with it. Does anyone see a glaring error that I'm making somewhere? I've tried this code on the VS2005 device emulator and on an HP iPAQ h5455.
 
Last edited:

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