|
Use QueryPerformanceFrequency / QueryPerformanceCounter . The resolution is in the microsecond range.
However, if you are trying something that depends on accurate timer intervals (i.e. realtime) then Windows is the wrong OS.
|
|
|
|
|
I know, thanks . The intervals don´t have to be that accurate but I´d generally need time-slices below <= 5ms.
I just wrote a little test program that acts as a millisecond stopwatch, once with Win32 System Timer and once with MM timer. The funny thing is, under Vista OS I find the behaviour described in the paper. 15.6 ms minimum sleep intervals with System timer and 1-2 ms accuracy with MM timer. But under Windows XP both have 15.6 ms, even the MM timer! This thing is driving me crazy ... I almost feel like the computers have actually united to bring down my sanity ...
Souldrift
|
|
|
|
|
Did you use timeGetDevCaps and timeBeginPeriod to query/set the resolution?
I used these functions a loooong time ago and I vaguely remember that you tinker with the driver this way.
|
|
|
|
|
Yes, I did. And it gave me a possible resulution of 1ms ... *&/%$+#^^°*
Souldrift
|
|
|
|
|
Souldrift wrote: And it gave me a possible resulution of 1ms
Which is reasonably accurate but it is at best an approximation. Running your program multiple times will likely produce different results because the amount of data in the cache changes and will thus require more/less CPU cycles to execute.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
If you look up multimedia timers in MSDN, you'll find they're marked obsolete and that you should use TimerQueueTimers instead (remember them?).
As I believe I mentioned before, even when you get round the timer resolution thing, you will not reliably avoid the issue of the Windows scheduler giving another thread a time-slice, so causing you to miss your required time by up to 1 time-slice quantum. The only way you can get that reliability is with a proper real-time operating system, like VxWorks or a real-time Linux. Windows is not designed to give you that reliability - it's designed to give optimum throughput and user responsiveness.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Of course you´re right and I know it´s obsolete (I had actually already TimerQueueTimer implemented). But still MM Timer should work, obsolete or not.
We´re taking a different approach now. Adjusting the client side processing of the data.
The one and only conclusion seems indeed to be that one shouldn´t go with Windows ...
Souldrift
|
|
|
|
|
Souldrift wrote: The one and only conclusion seems indeed to be that one shouldn´t go with Windows
For anything with significant real-time properties, that's pretty much true.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
in my appliacation i created two dialog boxes.each dialog box contains two text boxes and one button.if i enter data in two text boxes and click the button the data should be reflected in second dilog box and vice versa .all this should be done using socket programming..please let me know the solution
kir_MFC
|
|
|
|
|
|
Hello,
I have designed a console application in C++. In the application, I am capturing logoff/shutdown events using SetConsoleCtrlHandler() function. The application is working correctly in Windows 2000 - Windows XP but does not work in Windows Vista/7. Please help.
|
|
|
|
|
Look at status codes being returned - if it works in 2000 and XP, but not Vista or 7, the obvious suggested answer is 'something to do with security'...
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hi All,
I have a problem. I want to open an .htm file in default browser(firefox), so i use ShellExecute() function.
It opens a blank page. When i put in that directory another file with the same name it opens properly.
So the problem cannot regard to file path. And i have tried another thing: if I drag and drop the .htm file into either ie or firefox, it displays correctly.
The code is here:
std::wstring url = "file:///C:/DOCUME~1/MACADA~1/LOCALS~1/Temp/messages.htm";
std::wstring defaultBrowser = getDefaultBrowser();
ShellExecute(NULL, NULL, defaultBrowser.c_str(), url.c_str(), NULL, SW_SHOWNORMAL);
Anyone has a clue what can be the reason of this problem?
Thanks
|
|
|
|
|
Try this -
ShellExecute(NULL, L"open", url.c_str(), NULL, NULL, SW_SHOWNORMAL);
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Hi Venera,
Instead of starting default browser, just pass the html file path to ShellExecute() . For instance, for staring microsoft.com,
ShellExecute(NULL, NULL, "www.microsoft.com", 0, NULL, SW_SHOWNORMAL);
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
venera_soft wrote: std::wstring defaultBrowser = getDefaultBrowser();
You don't have to worry about finding out the default browser. A call to ShellExecute will do that for you.
venera_soft wrote: ShellExecute(NULL, NULL, defaultBrowser.c_str(), url.c_str(), NULL, SW_SHOWNORMAL);
You may have to worry more about passing NULL as the verb. Pass _T("open") as the verb and pass the complete URL as the file to be opened.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Thanks for quick reply.
I found that there was an encoding problem.
|
|
|
|
|
Hi to all,
I have a abstract class
class A
{
public:
void fn()=0;
//other functions
}
one derive class
Now I need to make one more class B, which will derive from A....here I will implement one function of A...and I need to declare a pointer to class B and pass it to a function called fun2().....How to do that?
Please help me out....
-----------------------------
I am a beginner
|
|
|
|
|
can u please clear the scneario?
|
|
|
|
|
I have a abstract class
class A
{
public:
void fn1()=0;
//other functions
};
I have another class B
class B : public A
{
void fn1()
{
}
};
in class B I have implement one function of A ie fn1... I need to declare a pointer to class B and pass it to some other function called funMain() in main function.....something like
B *ptr;
funMain(ptr);
My doubt::
Should I write B *ptr or
B *ptr = new B();
-----------------------------
I am a beginner
|
|
|
|
|
Are meaning about the need of allocation?
if u dont have member variables in class B or class A then you can write
B* ptr = 0;
funMain(ptr);
else
you have use to allocate it
B *ptr = new B();
|
|
|
|
|
himangshuS wrote: B *ptr;
funMain(ptr);
My doubt::
Should I write B *ptr or
B *ptr = new B();
of course you've to initialize the pointer (i.e. create an instance of the class)
and then call the function, for instance:
B * ptr;
ptr = new B();
funMain(ptr);
BTW what has it to do with abstract classes?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
himangshuS wrote: void fn()=0;
This is not allowed without the virtual keyword.
It should be virtual void fn()=0;
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
So one of my (many) recent questions ellicited a link to Resource Acquisition Is Initialization[^]. The wikipedia entry made sense and it seemed like, in general, this structure would be a good idea.
So now I'm using std::vector for the first time since my RAII introduction, and I recall that vector<> leaks unless I call vector<>.clear() when I'm done with the vector.
Does that mean, considering RAII, that whenever I want to use std::vector the best-practice method would be to write a specialized container class that calls .clear() in the destructor and exposes all the std::vector methods?
Now that I think of it, the container could be written as a template class.... but I'm going to let the question stand, since I'm just learning about RAII...
Is this an exception to the rule, or would a container class be best?
A thousand praises to all those who exhibit patience with the noob!
MZR
|
|
|
|
|
Mike the Red wrote: I recall that vector<> leaks unless I call vector<>.clear() when I'm done with the vector.
You recall incorrectly vector deallocates and calls the destructor of each contained object when it's destructed.
Mike the Red wrote: Does that mean, considering RAII, that whenever I want to use std::vector the best-practice method would be to write a specialized container class that calls .clear() in the destructor and exposes all the std::vector methods?
No - just use vector.
All STL container classes are (minus trivial bugs) intended to have that behaviour, i.e. they destruct the contained elements and deallocate their storage when destructed.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|