Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

real time clock in VC++

Posted on 1997-06-11
2
Medium Priority
?
856 Views
Last Modified: 2013-12-04
Hi,

Hi,

I want to write a program in Visual C++ 5.0 using MFC, which uses some kind of "real time clock".

Ok, when the program starts, the clock should start with time unit 0. Then it should count the time units in 1/10 of a second.

From my experiences with Java, I thought about using a thread, in which the clock will run. It should only count the time units and return the current, when asked for.
The main thread would then do the main work and whenever something new must be done, it should call the clock to ask for the "time". If the time is right, the next thing can be done.

Another idea is to use the function "_ftime" which returns the current time, I guess. The problem then can be the necessary calculation to do to translate the time struct to the appropriate time units. I think, this needs too much time.

It would be nice, if you could tell me which way would be the easiest(using threads, _ftime or another). It would be fine too, if you could give an example by including some example source code.

Thanks in advance, re.
0
Comment
Question by:re
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 23

Accepted Solution

by:
chensu earned 300 total points
ID: 1398168
I think the easiest way is to call Win32 Multimedia function timeGetTime(). The timeGetTime function retrieves the system time, in milliseconds. The system time is the time elapsed since Windows was started. Its default precision is enough for your case. When your program starts, call timeGetTime() to record the starting time
m_dwStart = ::timeGetTime();

When you need the current time unit, do the following
DWORD dwUnit = (::timeGetTime() - m_dwStart) / 100;

0
 

Author Comment

by:re
ID: 1398169
I checked the function "timeGetTime" in a small console application and it seems to run fast enough, for what I have to do.

Thanks for your help again, re.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

zlib is a free compression library (a DLL) on which the popular gzip utility is built.  In this article, we'll see how to use the zlib functions to compress and decompress data in memory; that is, without needing to use a temporary file.  We'll be c…
For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question