次の方法で共有


OEMGetRealTime (Compact 2013)

10/16/2014

This function is retrieves the local time from the real-time clock (RTC).

Syntax

BOOL OEMGetRealTime(
  LPSYSTEMTIME lpst 
);

Parameters

  • lpst
    [out] Pointer to the SYSTEMTIME structure that contains the current time.

Return Value

TRUE indicates success. FALSE indicates failure.

Remarks

This function must be re-entrant and must protect the hardware from being accessed multiple times.

In the OAL code, store the year value so it supports a 100-year range. For example, 1950-2050.

This function is called by the kernel function GetSystemTime, whether the clock is running in hardware mode or software mode. In hardware mode, this function queries the RTC. In software mode, the kernel makes fewer calls to OEMGetRealTime because a clock is simulated in software based on GetTickCount, which tracks clock ticks using the timer. To specify software mode for the clock, set HKEY_LOCAL_MACHINE\Platform\"SoftRTC" = 1. This registry key must be set at boot time to have any effect. In software mode, the functions OEMGetRealTime, OEMSetRealTime, and OEMSetAlarmTime are still used.

This function should not return a year earlier than 1601.

Note

In Windows Embedded Compact, the system behaves as if the real-time clock were maintained in Universal Coordinated Time (UTC). However, for backward compatibility, the underlying hardware clock is maintained in local time.

Example

The following code sample shows how to make this function re-entrant.

Important

For readability, the following code example does not contain security checking or error handling. Do not use the following code in a production environment.

BOOL OEMGetRealTime ( __out LPSYSTEMTIME lpst)
{
    BOOL RetVal;
    EnterCriticalSection(&RTC_critsect);
    // Code to get the time
    RetVal = Bare_GetRealTime(lpst);
    LeaveCriticalSection(&RTC_critsect);

    return RetVal;
}

Requirements

Header

nkintr.h

Library

OEMMain.lib or OEMMain_StaticKITL.lib

See Also

Reference

Required OAL Functions
OEMIdle
OEMSetAlarmTime