What do you mean by it's not working? It's not compiling? It's not giving you the expected output? It's crashing?
26 Replies - 552 Views - Last Post: 10 February 2013 - 03:17 PM
#17
Re: Get battery device name
Posted 09 February 2013 - 07:29 AM
it just wont print anything i think i am passing in the BateryManufactureDate structure wrongly. The if starement above the cout is not getting called.
#18
Re: Get battery device name
Posted 09 February 2013 - 07:41 AM
Well, find out if the the DeviceIoControl() call is succeeding or not. Step through the code with a debugger and find out.
If you are too lazy to learn how to use a debugger, change the code from:
to
If you are too lazy to learn how to use a debugger, change the code from:
if (DeviceIoControl(...))
{
// Do something with the results
}
to
if (DeviceIoControl(...))
{
// Do something with the results
}
else
{
cout << "DeviceIoControl() failed with error code: " << GetLastError() << endl;
}
#19
Re: Get battery device name
Posted 09 February 2013 - 07:52 AM
it dosnt make it through the DeviceIoControl the cout statement is never called i know this because right at the beginning of the if statement i put cout<<"Hello" and hello was never printed
#20
Re: Get battery device name
Posted 09 February 2013 - 07:59 AM
Can you post your code with the cout << "Hello"; ? It is ambiguous to me where you placed the printing code.
Without seeing your code, as best as I can tell the DeviceIoControl() call failed. Using GetLastError() as I showed above would help you diagnose why it failed.
Without seeing your code, as best as I can tell the DeviceIoControl() call failed. Using GetLastError() as I showed above would help you diagnose why it failed.
#21
Re: Get battery device name
Posted 09 February 2013 - 08:11 AM
using your get last error i got DeviceIoControl() failed with error code: 1
#22
Re: Get battery device name
Posted 09 February 2013 - 08:17 AM
Looking at winerror.h, that says:
So it looks like that device doesn't support querying the manufacture date.
// // MessageId: ERROR_INVALID_FUNCTION // // MessageText: // // Incorrect function. // #define ERROR_INVALID_FUNCTION 1L // dderror
So it looks like that device doesn't support querying the manufacture date.
#23
Re: Get battery device name
Posted 09 February 2013 - 08:22 AM
so the error is with my system not with my code
#24
Re: Get battery device name
Posted 09 February 2013 - 09:01 AM
is their a way i can get this information another way
#25
Re: Get battery device name
Posted 10 February 2013 - 02:35 PM
Write your own device driver that supports that particular query.
#26
Re: Get battery device name
Posted 10 February 2013 - 02:43 PM
but how can i know if my battery even has this information available
#27
Re: Get battery device name
Posted 10 February 2013 - 03:17 PM
You don't unless you interrogate the battery directly. The only way to interrogate it directly with any degree of certainty is to access the hardware without intermediaries. (This is why electronic voting can be very scary without appropriate oversight and transparency.)
|
|

New Topic/Question
Reply




MultiQuote



|