|
Force Code wrote: Try it out for yourself. Set an interval of 10 (milliseconds) and every WM_TIMER msg, OutputDebugString(GetCurrentTime()). The millisecond output will increment by 10 for at least fifty iterations before being off by one.
ummm - are they using the same clock? I think you'd need to compare the values against a
real-time clock.
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Force Code wrote: Try it out for yourself. Set an interval of 10 (milliseconds) and every WM_TIMER msg, OutputDebugString(GetCurrentTime()). The millisecond output will increment by 10 for at least fifty iterations before being off by one.
Mark Salsbery wrote:
ummm - are they using the same clock? I think you'd need to compare the values against a real-time clock.
I just tried it with QueryPerformanceCounter. It showed the WM_TIMER msgs were only off by an average of .0032%.
According to the SDK docs, QueryPerformanceCounter returns TRUE "if the installed hardware supports a high-resolution performance counter" (which it did in my case).
-- modified at 16:52 Tuesday 19th June, 2007
|
|
|
|
|
Well that's good news.
The most troubles I've ever had programming (and I'm still dealing with it now) is trying to
get any kind of close-to-real-time timing on a PC.
On my dual Xeon XP development machine, I get very precise timing. On another P4 Windows 2000
box I have, the timing is horrible. How much is OS, how much is hardware, I still have no idea.
I do know I have to synchronize certain timings between them (and more importantly, between
customer machines)) in real-time and it's a nightmare
Some possibly interesting articles...
Time is the Simplest thing...[^]
Precision is not the same as accuracy[^]
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Mark Salsbery wrote: Some possibly interesting articles...
Time is the Simplest thing...[^]
Precision is not the same as accuracy[^]
From Precision is not the same as accuracy[^]: "If you're looking for high accuracy, then you'd be better off playing around with the QueryPerformanceCounter function."
|
|
|
|
|
Right I'm dealing with varying 3rd party hardware clocks.
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Force Code wrote: I just tried it with QueryPerformanceCounter. It showed the WM_TIMER msgs were only off by an average of .0032%.
Correction: It was actually .0032, or .32%.
|
|
|
|
|
Hi,
We have an install batch file which needs to run at administrator level on all machines on our network. Is there a way to temporarily switch to administrator level programmatically?
Cheers,
Tony
|
|
|
|
|
You want to challenge windows security !
|| ART OF LIVING ||
|
|
|
|
|
Check out LogonUser() , ImpersonateLoggedOnUser() , and CreateProcessAsUser() .
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
First off, I'm running Visual C++ 6.0. I've got a DLL project that runs a batch file that uses the Message Compiler to create the .rc and .h file from a .mc file, then uses the Resource Compiler to create the .res file, and finally uses the linker to create the DLL from the .res file. What I'd like to do is to get the VERSIONINFO information into the .res or .rc file so that we can see this version information in the DLL when the user right clicks on the DLL in Explorer and selects Properties. Does anyone know a way to do this?
|
|
|
|
|
I don't know of a prepackaged way, but you should do it with a bit of programming.
1/ Make a resource only dll, and create the VERSIONINFO in it the way you'd like.
2/ Make a small program to merge the version resource into the MC created one - Have a look at BeginUpdateResource, UpdateResource, EndUpdateResource for the MC one, and FindResource et al for the versioninfo one.
3/ Add the mergeres.exe program to your custom build steps.
I didn't say it would be eeeeasy....
Iain.
|
|
|
|
|
What and where is mergeres.exe?
|
|
|
|
|
It's the program you write for yourself in step 2...
Iain.
|
|
|
|
|
Hi
In one of my application crashes sometime.
I used _CRTDBG_MAP_ALLOC and _CrtMemState() to set set points in various location of application and compared to find the leak. Sometime it alerts for memory leaks and sometimes not.
Could any way to locate the exact file/line which creates the problem?
Also I like to know can I use the _CRTDBG_MAP_ALLOC in AIX platform, or any equivalent?
Thanks
Krishnakumar
|
|
|
|
|
Do you want to find why your app crashes or find memory leaks?
Mamory leaks don't necessarily cause crashes...
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
I want to find why my applicaiton is failing. But my primary investigation there some code which are free() memory which are not properly allocated. I used Visual studio 6.0 debugger to do so.
So anything which helps to point out from which location/line/file the problem occurs will be helpful.
thanks
Krishnakumar
|
|
|
|
|
|
krishnakumar75 wrote: I used _CRTDBG_MAP_ALLOC and _CrtMemState() to set set points in various location of application and compared to find the leak. Sometime it alerts for memory leaks and sometimes not.
Where you do checkpoints can effect the results. You need to make sure no allocations that
aren't freed are made between checkpoints.
I prefer to use a static class object so I can catch all leaks (except possibly any in other
static objects) that occur over the lifetime of the app.
I use this in one (usually the main) source module:
#ifdef _DEBUG
class _MemStateCheck
{
public:
CMemoryState oldMemState, newMemState, diffMemState;
_MemStateCheck();
~_MemStateCheck();
};
_MemStateCheck::_MemStateCheck()
{
oldMemState.Checkpoint();
}
_MemStateCheck::~_MemStateCheck()
{
newMemState.Checkpoint();
if( diffMemState.Difference( oldMemState, newMemState ) )
{
TRACE( "************************\n" );
TRACE( "Memory leaks Detected\n" );
TRACE( "************************\n" );
diffMemState.DumpStatistics();
diffMemState.DumpAllObjectsSince();
}
else
{
TRACE( "************************\n" );
TRACE( "No memory leaks Detected\n" );
TRACE( "************************\n" );
}
}
_MemStateCheck MemCheckObj;
#endif //#ifdef _DEBUG
For MFC apps, I include this at the top of every source (cpp) file (under any #include lines):
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
To get file/line numbers for malloc, you should use _malloc_dbg instead of malloc (it will use the regular malloc in non-debug builds):
void *p = _malloc_dbg(128, _NORMAL_BLOCK, __FILE__, __LINE__ );
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
One more item - if you're coding in C++ and using malloc(), you might consider switching to
using new and delete instead!
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
I've created a custom control (a la article by Chris) to display a region of a bitmap. The control has vertical and a horizontal markers manipulated with the OnLButtonDown/OnLButtonUp/OnMouseMove handlers. The control is placed in a dialog. Now I'd like to add OnKeyDown support. Unfortunately, the dialog traps the WM_KEYDOWN message and just advances to the next control!
How do I get the WM_KEYDOWN message to the custom control?
Regards,
Kylur
|
|
|
|
|
Have a look at WM_GETDLGCODE / ON_WM_GETDLGCODE. That should answer your questions!
Iain.
|
|
|
|
|
Thanks! Exactly what I needed.
|
|
|
|
|
Hi all,
I am using CDynamicAccessor, CTable and other OLEDB API for database programming. I have a problem while inserting date field.
I am reading the date field from text file and the format of date is "M/d/yyyy". If System date format (Control Panel > Regional and Langauage Options) is "d/M/yyyy", then GetValue(Ordinal) retrieves NULL (in case of date greater than 12).
How to retrieve date field whatever may be the format of system date?
Thanks.
|
|
|
|
|
I'm in the unfortunate position of having to interact with mscorlib ( the .NET core library ) via COM. So I used regasm to generate a tlb of mscorlib and included the headers into my project. The headers build just fine in the debug build of the application, but the release build blows up with errors like this:
error C2628: '$S73' followed by 'void' is illegal (did you forget a ';'?)
error C2628: '$S74' followed by 'void' is illegal (did you forget a ';'?)
error C2628: '$S75' followed by 'void' is illegal (did you forget a ';'?)
(which as a result leads to a whole lot of other errors)
Which correspond to the following:
struct __declspec(uuid("b36b5c63-42ef-38bc-a07e-0b34c98f164a"))
/* dual interface */ _Exception;
struct __declspec(uuid("bca8b44d-aad6-3a86-8ab7-03349f4f2da2"))
/* interface */ _Type;
struct __declspec(uuid("35d574bf-7a4f-3588-8c19-12212a0fe4dc"))
/* dual interface */ IDictionaryEnumerator;
I haven't done anything that would introduce syntax errors into this file. Has anyone seen anything like this before?
I'm using Visual C++ 6 (I know I know. It's not my decision).
Thanks,
Stephen
-- modified at 10:02 Tuesday 19th June, 2007
I'm constantly improving every aspect of life. Not just my music, my rhymes but every facet requires its due attention to shine.
|
|
|
|
|
The __declspec extension to support uuid may have been added after VC++6. I certainly never used it way back when. I don't have any docs capped at VC6 so I can't confirm it.
I'd use the old style
<br />
const IID IID_ISomeControl = {0x2212DD08,0x71C8,0x409d,{0x8A,0x50,0x96,0x66,0x12,0x16,0x6E,0xA8}};<br />
instead.
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|