|
Interesting - I wouldn't expect that.
I guess you could add the null terminator yourself:
wchar_t szBatteryDeviceName[260];
bqi.InformationLevel = BatteryDeviceName;
if(DeviceIoControl(hBattery,IOCTL_BATTERY_QUERY_INFORMATION,&bqi,sizeof(bqi),szBatteryDeviceName,sizeof(szBatteryDeviceName),&dwOut,NULL))
{
szBatteryDeviceName[dwOut/sizeof(wchar_t)] = 0;
...
}
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Ahh now it works fine.
Great help, thanks!
bye,
gabbana
|
|
|
|
|
Okay,
now i tried this with another type. I only get -1 as seconds, i am not sure if this is for a constant that the estimatedtime value is not available, but is the way correct for getting them:
estimated time should return as an ULONG.
ULONG estimatedtime;
bqi.InformationLevel = BatteryEstimatedTime;
DeviceIoControl(hBattery,IOCTL_BATTERY_QUERY_INFORMATION,&bqi,sizeof(bqi),&estimatedtime,sizeof(ULONG),&dwOut,NULL);
wchar_t szestimatedtime[260];
wsprintf(szestimatedtime,L"%d seconds",estimatedtime);
MessageBox(NULL,szestimatedtime,L"",0);
Thanks for help!
bye,
gabbana
|
|
|
|
|
gabbana wrote: I only get -1 as seconds
-1 == 0xFFFFFFFF == BATTERY_UNKNOWN_TIME (BatClass.h)
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
From MSDN, if the estimated time is unknown (for example, the battery is not discharging and the AtRate specified was 0) this will return BATTERY_UNKNOWN_TIME .
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
How can I capture the default keys on a windows mobile phone that open messaging, internet explorer and even start button.
I want to be able to capture those and then disallow windows itself to open messaging application.
I know this is bad to do but I have to make an app to lock phone and I cannot allow any other application to be run by user.
Thanks in advance
-----------------------------
In my dream, I was dorwning my §orrow§
But my §orrow§, they learned to §wim
|
|
|
|
|
Both are aready in XP style.
BTW, I don't understand why M$ make them differenct in width.
system
|
|
|
|
|
CComboBox wraps the Windows combo box control.
CMFCColorButton is a control implemented in a library.
Why the author(s) chose not to use the system width metric, I don't know.
CMFCColorButton was not written by Microsoft AFAIK.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hello everyone,
For the following code, I can not set breakpoint in release mode, but the same command in WinDbg works fine in debug mode. Anything wrong?
Here is my Windbg command and output in release mode and source codes. I have tested in release mode breakpoint at foo does not take effect, but in debug mode it takes effect.
0:000> bp foo
Bp expression 'foo' could not be resolved, adding deferred bp
0:000> bp main
0:000> bl
0 eu 0001 (0001) (foo)
1 e 00000001`40001000 0001 (0001) 0:**** Test64bitDebug!main
int foo (int a, int b)
{
return a+b;
}
int main()
{
int a1 = 100;
int b1 = a1 + 100;
a1 = foo (a1, b1);
return 0;
}
thanks in advance,
George
|
|
|
|
|
Hi George,
could you please tell us why you need breakpoints for release mode applications? You also have the debug mode to debug your application. Don't you think is enought?
Best regards,
Mihai Moga
|
|
|
|
|
Thanks Mihai,
Because in real test environment, we need to work with release mode code, not debug mode code. Anyway, any ideas to my original question?
regards,
George
|
|
|
|
|
Hi George,
I do not have an answer to your original question, but did you read Keith Rule's Debugging Release Mode Problems[^] article?
Best regards,
Mihai Moga
|
|
|
|
|
Thanks Mihai,
I read through the article, looks great! A few more comments,
1. We could only use VERIFY in MFC based application, corrrect?
2. In the article it is mentioned "In my personal experience, I've rarely seen a problem that really was bad code generation. My experience with VC++ 6.0 has been that the compiler occasionally asserts while generating code (especially when using templates), but I've not experienced any problem with my code associated with bad code generation. Installing service release 3 seems to have taken care of all the code generation asserts that I've seen in previous versions."
What means "asserts" here?
regards,
George
|
|
|
|
|
Hi George,
to answer to your questions I gently ask you to read couple more articles:
a) Rob Manderson's Assert is your friend[^]
b) srana's MFC Windows Coding Guidelines[^]
Best regards,
Mihai Moga
P.S. YES, you should use only
VERIFY to ensure that your code goes to release version of your application; use
ASSERT only for definitions/expressions/assertions.
|
|
|
|
|
Thanks Mihai,
I have read through the article. And I want to confirm with you that VERIFY could only be used with MFC application, correct?
regards,
George
|
|
|
|
|
Yes George, you are right.
Best regards,
Mihai Moga
|
|
|
|
|
|
It's not enough. Although you should debug in the debug build most times there are classes of bugs that only manifest in release builds.
Steve
|
|
|
|
|
Thanks Steve,
Any comments to my original question?
regards,
George
|
|
|
|
|
I think, in release mode, the code may be optimized, so the binary codes may not map to the source code, so it doesn't support break point in source code.
system
|
|
|
|
|
Thanks followait!
Do you have any ideas to check whether a function is optimized out or not?
regards,
George
|
|
|
|
|
just do some settings -
Settings->Link - Check - Generate Debug Info
Settings->C/C++ - Select Disable/Debug in Optimazations Combo
- Check Generate Browse Info
- Select "Program Database" in Debug Info Combo
Complile the application
You can debug the release mode.
-@SuDhIrKuMaR@-
|
|
|
|
|
Thanks sudhir_Kumar,
What are the so-called debug information contains? I think symbols are in PDB file and what are else debug info for release binary code?
regards,
George
|
|
|
|
|
The debug information is what's contained in PDB files. It contains a myriad of information including:
- Mappings from addresses to source files and line numbers.
- The layout of structures and classes.
- Type information.
- Stack layout so local variables can be examined.
Basically all the information the debugger needs.
Steve
|
|
|
|
|
Thanks Steve,
Even if I do not turn on the debug information, there is still the PDB file. You mean if I do not turn on the option, PDB will not be generated? Or?
regards,
George
|
|
|
|