Get battery device name

  • (2 Pages)
  • +
  • 1
  • 2

26 Replies - 1216 Views - Last Post: 10 February 2013 - 03:17 PM Rate Topic: -----

#16 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 3183
  • View blog
  • Posts: 9,652
  • Joined: 05-May 12

Re: Get battery device name

Posted 09 February 2013 - 06:56 AM

What do you mean by it's not working? It's not compiling? It's not giving you the expected output? It's crashing?
Was This Post Helpful? 0
  • +
  • -

#17 popgalop  Icon User is offline

  • D.I.C Head

Reputation: -2
  • View blog
  • Posts: 65
  • Joined: 08-November 12

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.
Was This Post Helpful? 0
  • +
  • -

#18 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 3183
  • View blog
  • Posts: 9,652
  • Joined: 05-May 12

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:
if (DeviceIoControl(...))
{
    // Do something with the results
}



to
if (DeviceIoControl(...))
{
    // Do something with the results
}
else
{
    cout << "DeviceIoControl() failed with error code: " << GetLastError() << endl;
}


Was This Post Helpful? 0
  • +
  • -

#19 popgalop  Icon User is offline

  • D.I.C Head

Reputation: -2
  • View blog
  • Posts: 65
  • Joined: 08-November 12

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
Was This Post Helpful? 0
  • +
  • -

#20 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 3183
  • View blog
  • Posts: 9,652
  • Joined: 05-May 12

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.
Was This Post Helpful? 0
  • +
  • -

#21 popgalop  Icon User is offline

  • D.I.C Head

Reputation: -2
  • View blog
  • Posts: 65
  • Joined: 08-November 12

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
Was This Post Helpful? 0
  • +
  • -

#22 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 3183
  • View blog
  • Posts: 9,652
  • Joined: 05-May 12

Re: Get battery device name

Posted 09 February 2013 - 08:17 AM

Looking at winerror.h, that says:
//
// 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.
Was This Post Helpful? 0
  • +
  • -

#23 popgalop  Icon User is offline

  • D.I.C Head

Reputation: -2
  • View blog
  • Posts: 65
  • Joined: 08-November 12

Re: Get battery device name

Posted 09 February 2013 - 08:22 AM

so the error is with my system not with my code
Was This Post Helpful? 0
  • +
  • -

#24 popgalop  Icon User is offline

  • D.I.C Head

Reputation: -2
  • View blog
  • Posts: 65
  • Joined: 08-November 12

Re: Get battery device name

Posted 09 February 2013 - 09:01 AM

is their a way i can get this information another way
Was This Post Helpful? 0
  • +
  • -

#25 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 3183
  • View blog
  • Posts: 9,652
  • Joined: 05-May 12

Re: Get battery device name

Posted 10 February 2013 - 02:35 PM

Write your own device driver that supports that particular query.
Was This Post Helpful? 0
  • +
  • -

#26 popgalop  Icon User is offline

  • D.I.C Head

Reputation: -2
  • View blog
  • Posts: 65
  • Joined: 08-November 12

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
Was This Post Helpful? 0
  • +
  • -

#27 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 3183
  • View blog
  • Posts: 9,652
  • Joined: 05-May 12

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.)
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2