VirtualBox

source: vbox/trunk/src/VBox/Runtime/testcase/ntGetTimerResolution.cpp@ 4071

Last change on this file since 4071 was 4071, checked in by vboxsync, 17 years ago

Biggest check-in ever. New source code headers for all (C) innotek files.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.5 KB
Line 
1/* $Id: ntGetTimerResolution.cpp 4071 2007-08-07 17:07:59Z vboxsync $ */
2/** @file
3 * innotek Portable Runtime - Win32 (NT) testcase for getting the timer resolution.
4 */
5
6/*
7 * Copyright (C) 2006-2007 innotek GmbH
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License as published by the Free Software Foundation,
13 * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
14 * distribution. VirtualBox OSE is distributed in the hope that it will
15 * be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18
19/*******************************************************************************
20* Header Files *
21*******************************************************************************/
22#define _WIN32_WINNT 0x0500
23#include <Windows.h>
24#include <stdio.h>
25
26extern "C" {
27/* from sysinternals. */
28NTSYSAPI LONG NTAPI NtQueryTimerResolution(OUT PULONG MinimumResolution, OUT PULONG MaximumResolution, OUT PULONG CurrentResolution);
29}
30
31
32int main()
33{
34 ULONG Min = ~0;
35 ULONG Max = ~0;
36 ULONG Cur = ~0;
37 NtQueryTimerResolution(&Min, &Max, &Cur);
38 printf("NtQueryTimerResolution -> Min=%lu Max=%lu Cur=%lu (100ns)\n", Min, Max, Cur);
39
40#if 0
41 /* figure out the 100ns relative to the 1970 epoc. */
42 SYSTEMTIME st;
43 st.wYear = 1970;
44 st.wMonth = 1;
45 st.wDayOfWeek = 4; /* Thor's day. */
46 st.wDay = 1;
47 st.wHour = 0;
48 st.wMinute = 0;
49 st.wSecond = 0;
50 st.wMilliseconds = 0;
51
52 FILETIME ft;
53 if (SystemTimeToFileTime(&st, &ft))
54 {
55 printf("epoc is %I64u (0x%08x%08x)\n", ft, ft.dwHighDateTime, ft.dwLowDateTime);
56 if (FileTimeToSystemTime(&ft, &st))
57 printf("unix epoc: %d-%02d-%02d %02d:%02d:%02d.%03d (week day %d)\n",
58 st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond, st.wMilliseconds, st.wDayOfWeek);
59 else
60 printf("FileTimeToSystemTime failed, lasterr=%d\n", GetLastError());
61 }
62 else
63 printf("SystemTimeToFileTime failed, lasterr=%d\n", GetLastError());
64
65 ft.dwHighDateTime = 0;
66 ft.dwLowDateTime = 0;
67 if (FileTimeToSystemTime(&ft, &st))
68 printf("nt time start: %d-%02d-%02d %02d:%02d:%02d.%03d (week day %d)\n",
69 st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond, st.wMilliseconds, st.wDayOfWeek);
70 else
71 printf("FileTimeToSystemTime failed, lasterr=%d\n", GetLastError());
72#endif
73 return 0;
74}
75
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette