Re: BatClass.h
- From: Joseph M. Newcomer <newcomer@xxxxxxxxxxxx>
- Date: Sun, 10 Dec 2006 13:02:34 -0500
OK, now THAT'S useful.
Note that DEVICE_OBJECT is a kernel type, not a user type. Therefore, its use in an
application program is deeply suspect.
The error message you get is the typical error message presented when an undefined data
type is used. So that's the giveaway as to what is wrong. It tells you instantly that
PDEVICE_OBJECT is not defined.
In fact, there is no user-level header file that defines PDEVICE_OBJECT. Nor would it
make sense to have one, because a DEVICE_OBJECT exists *only* in the kernel.
I'm not sure why batclass.h even appears in the platform sdk; it looks like it is a kernel
header file somebody threw in by mistake.
Since you can never define that field, its presence is suspect. I strongly suspect that
this call cannot be used from user space.
You could use
typedef LPVOID PDEVICE_OBJECT;
which then leaves you with UNICODE_STRING as a data type to cause problems.
Note that you could never set PDEVICE_OBJECT to a meaningful value, so if you use other
than NULL here it would be an error.
Similarly, an IRP is solely and exclusively a kernel data type. It cannot exist in user
application space (it might exist in user space in a user-mode device driver, but we are
far from using that here!)
I strongly suspect that nearly everything in batclass.h (on a cursory reading) is
completely meaningless in user space, and its inclusion in the platform sdk header files
is a colossal mistake.
Note that including ntddk.h will cause more problems than it is worth; ntddk.h is
incompatible with user header files and will cause multiply-defined symbol errors and
other problems, and in any case, even though the symbols could be defined, the actual
things referenced cannot exist in user space and it would be meaningless to refer to them
from user space.
Someone at Microsoft screwed up on this one.
joe
On 9 Dec 2006 22:13:03 -0800, "HK" <HKahwaji@xxxxxxxxxxxxxx> wrote:
Joseph M. Newcomer [MVP]
Here are the errors:
Compiler: Default compiler
Building Makefile: "C:\Dev-Cpp\Battery_IOCTL_Sample\Makefile.win"
Executing make...
make.exe -f "C:\Dev-Cpp\Battery_IOCTL_Sample\Makefile.win" all
gcc.exe -D__DEBUG__ -c main.c -o main.o -I"C:/Dev-Cpp/include" -g3
In file included from main.c:9:
C:/Dev-Cpp/include/Batclass.h:290: error: syntax error before
"PDEVICE_OBJECT"
C:/Dev-Cpp/include/Batclass.h:290: warning: no semicolon at end of
struct or union
C:/Dev-Cpp/include/Batclass.h:292: error: syntax error before '}' token
C:/Dev-Cpp/include/Batclass.h:292: warning: data definition has no type
or storage class
C:/Dev-Cpp/include/Batclass.h:391: error: syntax error before
"MiniportInfo"
C:/Dev-Cpp/include/Batclass.h:405: error: syntax error before "PIRP"
C:/Dev-Cpp/include/Batclass.h:413: error: syntax error before
"PDEVICE_OBJECT"
C:/Dev-Cpp/include/Batclass.h:422: error: syntax error before
"PDEVICE_OBJECT"
make.exe: *** [main.o] Error 1
Joseph M. Newcomer wrote:
I seriously doubt you are getting "all kinds of errors". I strongly suspect you are
getting very specific error messages. Without seeing them, there is no way to guess what
might be wrong. Otherwise, your question is unanswerable.
joe
On 8 Dec 2006 16:08:40 -0800, "HK" <HKahwaji@xxxxxxxxxxxxxx> wrote:
Hi all,Joseph M. Newcomer [MVP]
I am experimenting in IOCTL_BATTERY_QUERY_INFORMATION to get more
detailed infromation about the battery and I was able to get good
information from MSDN.
1. My application has enumerated all devices that has battery class 2.
Created the handle after aquiring the name of the battery 3. Use
IOCTL_Battery_Query_tag to get the tag value and use that in
IOCTL_BATTERY_QUERY_INFORMATION
However I am looking at MSDN information and its says to include
BatClass.h. Unfortunately, when I do so I am getting all kinds of
errors within BatClass.h. Errors include syntax errors as well.
Any suggestions or ideas are appreciated
I am including <windows.h>
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.
- References:
- BatClass.h
- From: HK
- Re: BatClass.h
- From: Joseph M . Newcomer
- Re: BatClass.h
- From: HK
- BatClass.h
- Prev by Date: Re: display unicode db text in visual C++ mfc ide 2003
- Next by Date: Re: Distorted dialog title bar after SetWindowPos in OnInitDialog
- Previous by thread: Re: BatClass.h
- Next by thread: Recording Urls Entered in Web Browsers...............
- Index(es):
Relevant Pages
|