Hello everyone,
I'm a bit new to this forum, found some excellent posts that helped me alot on this new and advance project I'm working on.

I'm creating a program to control Vinyl Mastering Equipment, and the audio that goes with it. The problem I'm faced with is accurate timing. Seems some of the visual cues and processes I have are not working correctly due to the way that VB6's Timer works.

Is there an API or something I can do to get the timer more accurate, like ms accurate, or even better sample accurate?

Also is there an API that would replace gui32 that is a bit more effcient, seems some of my gui32 processes are hammering the CPU, and I'd like to free it up.

Thanks for you help!

Recommended Answers

All 2 Replies


Also is there an API that would replace gui32 that is a bit more effcient, seems some of my gui32 processes are hammering the CPU, and I'd like to free it up.

excuse me, gdi32..

The two APIs you're looking for are the following:

(1) QueryPerformanceFrequency

(2) QueryPerformanceCounter

The first API retrieves the timing resolution that your system is capable of: depends on your CPU. The Second API retrieves the actual time. VB6's timer's are not that accurate. These are the API's you're looking for.
The QueryPerformanceFrequency will tell you how many counts in a second your system is capable of. You use the second at the start and end of the events you wish to time. That will give you the counts that have have passed.

You'll need to do some investigation in the Platform SDK concerning more details.

Private Type LARGE_INTEGER
    LowPart As Long
    HighPart As Long
End Type
Private Declare Function QueryPerformanceCounter Lib "kernel32" (lpPerformanceCount As LARGE_INTEGER) As Long
Private Declare Function QueryPerformanceFrequency Lib "kernel32" (lpFrequency As LARGE_INTEGER) As Long
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.