473,842 Members | 1,773 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DeviceIoControl in C#

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

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

Please help me, thanks
Marina
Jun 27 '08 #1
4 3896
Hi Marina,

Assuming that you are our Marina then how is the baby going?

Did you try it already in the newsgroup
microsoft.publi c.dotnet.langua ges.compactfram ework
It is and has always been a rather active newsgroup

http://groups.google.com/group/micro...rch+this+group

Cor
"Marina" <Ma****@discuss ions.microsoft. comschreef in bericht
news:7F******** *************** ***********@mic rosoft.com...
Does any know any sample of how to do a basic DeviceIoControl with
something
like IOCTL_BATTERY_G ETSYSTEMPOWERST ATUSEX2 in C#

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

Please help me, thanks
Marina

Jun 27 '08 #2
Thank you but my mistake i meant to say:

DeviceIoControl using IOCTL_BATTERY_Q UERY_STATUS (NOT CE)

Any ideas, life is hard

Marina

"Cor Ligthert[MVP]" wrote:
Hi Marina,

Assuming that you are our Marina then how is the baby going?

Did you try it already in the newsgroup
microsoft.publi c.dotnet.langua ges.compactfram ework
It is and has always been a rather active newsgroup

http://groups.google.com/group/micro...rch+this+group

Cor
"Marina" <Ma****@discuss ions.microsoft. comschreef in bericht
news:7F******** *************** ***********@mic rosoft.com...
Does any know any sample of how to do a basic DeviceIoControl with
something
like IOCTL_BATTERY_G ETSYSTEMPOWERST ATUSEX2 in C#

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

Please help me, thanks
Marina
Jun 27 '08 #3
Marina,

There is a complete description in C++ for this how to handle this, should
be rather easy to tranform.

http://msdn.microsoft.com/en-us/libr...69(VS.85).aspx

Cor
"Marina" <Ma****@discuss ions.microsoft. comschreef in bericht
news:AE******** *************** ***********@mic rosoft.com...
Thank you but my mistake i meant to say:

DeviceIoControl using IOCTL_BATTERY_Q UERY_STATUS (NOT CE)

Any ideas, life is hard

Marina

"Cor Ligthert[MVP]" wrote:
>Hi Marina,

Assuming that you are our Marina then how is the baby going?

Did you try it already in the newsgroup
microsoft.publ ic.dotnet.langu ages.compactfra mework
It is and has always been a rather active newsgroup

http://groups.google.com/group/micro...rch+this+group

Cor
"Marina" <Ma****@discuss ions.microsoft. comschreef in bericht
news:7F******* *************** ************@mi crosoft.com...
Does any know any sample of how to do a basic DeviceIoControl with
something
like IOCTL_BATTERY_G ETSYSTEMPOWERST ATUSEX2 in C#

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

Please help me, thanks
Marina

Jun 27 '08 #4
Thank you YES this looks like what i need to do but in C# ??

The furthest i got is:

[DllImport("Kern el32.dll", SetLastError = false, CharSet =
CharSet.Auto)]
public static extern bool DeviceIoControl (
Microsoft.Win32 .SafeHandles.Sa feFileHandle hDevice,
EIOControlCode IoControlCode,
[MarshalAs(Unman agedType.AsAny)]
[In] object InBuffer,
uint nInBufferSize,
[MarshalAs(Unman agedType.AsAny)]
[Out] object OutBuffer,
uint nOutBufferSize,
ref uint pBytesReturned,
[In] ref System.Threadin g.NativeOverlap ped Overlapped);

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

Marina
"Cor Ligthert[MVP]" wrote:
Marina,

There is a complete description in C++ for this how to handle this, should
be rather easy to tranform.

http://msdn.microsoft.com/en-us/libr...69(VS.85).aspx

Cor
"Marina" <Ma****@discuss ions.microsoft. comschreef in bericht
news:AE******** *************** ***********@mic rosoft.com...
Thank you but my mistake i meant to say:

DeviceIoControl using IOCTL_BATTERY_Q UERY_STATUS (NOT CE)

Any ideas, life is hard

Marina

"Cor Ligthert[MVP]" wrote:
Hi Marina,

Assuming that you are our Marina then how is the baby going?

Did you try it already in the newsgroup
microsoft.publi c.dotnet.langua ges.compactfram ework
It is and has always been a rather active newsgroup

http://groups.google.com/group/micro...rch+this+group

Cor
"Marina" <Ma****@discuss ions.microsoft. comschreef in bericht
news:7F******** *************** ***********@mic rosoft.com...
Does any know any sample of how to do a basic DeviceIoControl with
something
like IOCTL_BATTERY_G ETSYSTEMPOWERST ATUSEX2 in C#

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

Please help me, thanks
Marina


Jun 27 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
840
by: ewoo | last post by:
I'm trying to write a wrapper in csharp to wrap DeviceIoControl() win32 method for IOCTL_VIDEO_QUERY_DISPLAY_BRIGHTNESS control code--without much luck. I've seen lots of examples out there for low-level file access but can't seem to any for the display. Can you provide some samples of how I might do this? Below is my code thus far...
2
5936
by: Jules Crown | last post by:
Everyone, greetings, newbee here. What I'm trying to do is to compress files on NTFS from C#. I've been fishing around for info and gathered the hereafter. I'd like to know what's wrong with it. public static extern int DeviceIoControl( IntPtr hDevice,
2
15559
by: Michael Allen | last post by:
I would like to perform something similar to the below function in C# .NET. The C++ below code is from a Microsoft DDK sample driver application. Specifically, I would like to perform Device I/O Control from a .NET application. Is there any way to do this in C#. I have tried Googling to no avail. Thanks, Michael Allen
3
8239
by: Jacky | last post by:
Hi, I am trying to make network card interface with VB.NET 2002. I use DeviceIOControl-function. I have tried to define inbuffer and outbuffer using byte array and it's pointer. The second I tried AllocHGlobal and Copy. They works nice though the old app set these parameters to heap and VB.NET to programs reserved memory area.
1
2531
by: Pixie | last post by:
I am trying to query the change journal using the deviceIOControl API. The API doesn't return an error, but all of the values in the output buffer are zero, and they shouldn't be. My code is below. I have also tried specifying different pack values in my USN_JOURNAL_DATA structure definition but this didn't change anything. Any help would be greatly appreciated Private Const FILE_SHARE_READ = &H1 Private Const FILE_SHARE_WRITE = &H2 Private...
0
2331
by: Pixie | last post by:
We are successfully getting a handle to a drive using createfile then using that handle to query the change journal using DeviceIOControl with the paramter FSCTL_QUERY_USN_DATA. However when we try to enumerate the change journal data using the same handle and using DeviceIOControl with FSCTL_ENUM_DATA it gives error 1 Incorrect function. The help says this means that the drive does not support change journals but this is not the case as we can...
1
4568
by: Juan Pedro Gonzalez | last post by:
Helo, I'm having problems here with the input buffer.... Ive defined the API call as: <System.Runtime.InteropServices.DllImport("kernel32", SetLastError:=True)> _ Private Shared Function DeviceIoControl(ByVal hDevice As IntPtr, ByVal dwIoControlCode As Integer, ByVal lpInBuffer As IntPtr, ByVal nInBuffer As Integer, ByRef lpOutBuffer As IntPtr, ByVal nOutBufferSize As Integer, ByRef lbBytesResturned As Integer, ByVal lpOverlapped As...
5
3812
by: Lou | last post by:
is there a VB .NET way to use the API "DeviceIoControl"? -Lou
0
1872
by: Andrew | last post by:
Hello I am trying to port some code and I am running into some issues I may or may not be able to solve on my own and would appreciate your help Basically I am trying to open the Tun Driver through openvpn in Ether (Tap mode). code is as follows f = win32file.CreateFile("C:\\WINDOWS\\System32\\drivers\\tunmp.sys", GENERIC_READ, 0, None, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0)
0
9865
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9709
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10609
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10668
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10303
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9446
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
7025
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5882
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3140
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.