Ich versuche, diese genaue Timer auf VS2008 zum Laufen zu bringen, auf Windows XP (und schließlich Server 2008) aus dem folgenden Beispiel:Multimedia-Timer? <mmsystem.h>
http://technology.chtsai.org/w98timer/
Jedoch habe ich die folgenden Fehler erhalten:
- Fehler LNK2019: nicht aufgelöstes externes Symbol _ imp _timeEndPeriod @ 4
- Fehler LNK2019: nicht aufgelöstes externes Symbol _ imp _timeGetTime @ 0
- Fehler LNK2019: nicht aufgelöstes externes Symbol _ imp _timeBeginPeriod @ 4
- Fehler LNK2019: nicht aufgelöstes externes Symbol _ imp _timeGetDevCaps @ 8
Könnte jemand bitte raten?
Ich möchte nur eine einfache, genaue, Millisekunde-Timing-Beispiel für C++ unter Windows.
#include <stdio.h>
#include <windows.h>
#include <mmsystem.h>
#include "stdafx.h"
void
main (void)
{
TIMECAPS resolution;
DWORD start, finish, duration, i;
if (timeGetDevCaps (&resolution, sizeof (TIMECAPS)) == TIMERR_NOERROR)
{
printf ("Minimum supported resolution = %d\n", resolution.wPeriodMin);
printf ("Maximum supported resolution = %d\n", resolution.wPeriodMax);
}
if (resolution.wPeriodMin <= 1)
{
if (timeBeginPeriod (1) == TIMERR_NOERROR)
{
for (i = 100; i <= 120; i++)
{
start = timeGetTime();
while (timeGetTime() < (start + i));
finish = timeGetTime();
duration = finish - start;
printf ("expected:%d actual:%ld\n", i, duration);
}
timeEndPeriod (1);
}
}
}