DeviceIoControl in C#

  • Thread starter Thread starter Marina
  • Start date Start date
M

Marina

Does any know any sample of how to do a basic DeviceIoControl with something
like IOCTL_BATTERY_GETSYSTEMPOWERSTATUSEX2 in C#

I have been stuck all week :(
and google doesnt yield anything of use.

Please help me, thanks
Marina
 
Thank you but my mistake i meant to say:

DeviceIoControl using IOCTL_BATTERY_QUERY_STATUS (NOT CE)

Any ideas, life is hard

Marina
 
Thank you YES this looks like what i need to do but in C# ??

The furthest i got is:

[DllImport("Kernel32.dll", SetLastError = false, CharSet =
CharSet.Auto)]
public static extern bool DeviceIoControl(
Microsoft.Win32.SafeHandles.SafeFileHandle hDevice,
EIOControlCode IoControlCode,
[MarshalAs(UnmanagedType.AsAny)]
[In] object InBuffer,
uint nInBufferSize,
[MarshalAs(UnmanagedType.AsAny)]
[Out] object OutBuffer,
uint nOutBufferSize,
ref uint pBytesReturned,
[In] ref System.Threading.NativeOverlapped Overlapped);

i think now i need to populate some structures but i cannot find any example
on google or anywhere?
Anymore ideas?

Marina
 

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

Back
Top