Search
Module:
Directory

   Desktop Functions:

   Smart Device Functions:


Show Recent Changes
Subscribe (RSS)
Misc. Pages
Comments
FAQ
Helpful Tools
Playground
Suggested Reading
Website TODO List
Download Visual Studio Add-In

Search Results for "SYSTEMTIME" in [All]

kernel32

.
Summary
.

static extern bool FileTimeToSystemTime([In] ref FILETIME lpFileTime,

.

   out SYSTEMTIME lpSystemTime);

.

   Friend Shared Function FileTimeToSystemTime( _

.

                        <Out()> ByRef lpSystemTime As SYSTEMTIME) _

.

FileTime and SystemTime.

.

    public static DateTime FileTimeToSystemTime(string hexTS) {

.
Documentation
[FileTimeToSystemTime] on MSDN
.

static extern int GetDateFormat(uint locale, uint dwFlags, ref SystemTime date, string format, StringBuilder sb, int sbSize);

.

SYSTEMTIME in Win32 is different then DateTime in CLR. This structure may represent SYSTEMTIME in CLR world:

.

    private struct SystemTime {

.

    static extern int GetDateFormat(int locale, uint dwFlags, ref SystemTime sysTime,

.

    private struct SystemTime {

.

        public SystemTime(DateTime dateTime) {

.

        SystemTime st = new SystemTime(dt);

.

static extern void GetLocalTime(out SYSTEMTIME lpSystemTime);

.

Shared Sub GetLocalTime(ByRef time As SYSTEMTIME)

.

If you want to get the current system date and time expressed in Coordinated Universal Time (UTC) format, use GetSystemTime instead.

.

See SYSTEMTIME.

.

   Private Structure SYSTEMTIME

.

   Private Shared Sub GetLocalTime(ByRef time As SYSTEMTIME)

.

     Dim currenttime As SYSTEMTIME

.

static extern bool GetSystemTimes (

.

    GetSystemTimes(out idleTime, out kernelTime, out userTime);

.
Documentation
[GetSystemTimes] on MSDN
.
Summary
.

static extern void GetSystemTimeAsFileTime(out FILETIME

.

   lpSystemTimeAsFileTime);

.

       public static extern void GetSystemTimeAsFileTime(out FILETIME lpSystemTimeAsFileTime);

.

        GetSystemTimeAsFileTime(out myTime);

.
Documentation
[GetSystemTimeAsFileTime] on MSDN
.

static extern bool GetSystemTimes (

.

    GetSystemTimes(out idleTime, out kernelTime, out userTime);

.
Documentation
[GetSystemTimes] on MSDN
.

static extern int GetTimeFormat(uint locale, uint dwFlags, ref SystemTime time, string format, StringBuilder sb, int sbSize);

.

SYSTEMTIME in Win32 is different then DateTime in CLR. This structure may represent SYSTEMTIME in CLR world:

.

    private struct SystemTime {

.

/// The SystemTime structure represents a date and time using individual members

.

private struct SystemTime {

.

  /// A SystemTime structure that contains a date and local time when the transition from daylight saving time to standard time occurs on this operating system. If the time zone does not support daylight saving time or if the caller needs to disable daylight saving time, the wMonth member in the SystemTime structure must be zero. If this date is specified, the DaylightDate value in the TimeZoneInformation structure must also be specified. Otherwise, the system assumes the time zone data is invalid and no changes will be applied.

.

  public SystemTime standardDate;

.

  /// A SystemTime structure that contains a date and local time when the transition from standard time to daylight saving time occurs on this operating system. If the time zone does not support daylight saving time or if the caller needs to disable daylight saving time, the wMonth member in the SystemTime structure must be zero. If this date is specified, the StandardDate value in the TimeZoneInformation structure must also be specified. Otherwise, the system assumes the time zone data is invalid and no changes will be applied.

.

  public SystemTime daylightDate;

.

static extern bool SetLocalTime([In] ref SYSTEMTIME lpLocalTime);

.

Shared Function SetLocalTime(ByRef time As SYSTEMTIME) As Boolean

.

    //I have added some methods to structure SYSTEMTIME. After that the convertion between System.DateTime and SYSTEM became much easier. :)

.

    //Sample code for SetLocalTime and SYSTEMTIME structure

.

        /// SYSTEMTIME structure with some useful methods

.

        public struct SYSTEMTIME

.

            public static DateTime ToDateTime(SYSTEMTIME time)

.

        public static extern bool SetLocalTime( ref SYSTEMTIME Time );

.

            //Convert to SYSTEMTIME

.

            SYSTEMTIME st = new SYSTEMTIME();

.

   Private Structure SYSTEMTIME

.

   Private Shared Sub GetLocalTime(ByRef time As SYSTEMTIME)

.

   Private Shared Function SetLocalTime(ByRef time As SYSTEMTIME) As Boolean

.

     Dim currentTime As SYSTEMTIME

.

static extern bool SetSystemTime(ref SYSTEMTIME time);

.

Shared Function SetSystemTime(ByRef time As SYSTEMTIME) As Boolean

.

SYSTEMTIME

.

Fill-in an instance of the SYSTEMTIME struct and call SetSystemTime(ref obj), where obj is the instance of your struct.

.

        public struct SYSTEMTIME

.

        /// <param name="lpSystemTime">[out] Pointer to a SYSTEMTIME structure to

.

        public extern static void GetSystemTime(ref SYSTEMTIME lpSystemTime);

.

        /// <param name="lpSystemTime">[in] Pointer to a SYSTEMTIME structure that

.

        public extern static uint SetSystemTime(ref SYSTEMTIME lpSystemTime);

.

            SYSTEMTIME st = new SYSTEMTIME();

.

            GetSystemTime(ref st);

.

            if (SetSystemTime(ref st) == 0)

.

                Console.WriteLine("FAILURE: SetSystemTime failed");

.

            SetSystemTime(ref st);

.
Documentation
[SetSystemTime] on MSDN
.

    /// The SystemTime structure represents a date and time using individual members

.

    public struct SystemTime

.

        /// A SystemTime structure that contains a date and local time when the transition from daylight saving time to standard time occurs on this operating system. If the time zone does not support daylight saving time or if the caller needs to disable daylight saving time, the wMonth member in the SystemTime structure must be zero. If this date is specified, the DaylightDate value in the TimeZoneInformation structure must also be specified. Otherwise, the system assumes the time zone data is invalid and no changes will be applied.

.

        public SystemTime standardDate;

.

        /// A SystemTime structure that contains a date and local time when the transition from standard time to daylight saving time occurs on this operating system. If the time zone does not support daylight saving time or if the caller needs to disable daylight saving time, the wMonth member in the SystemTime structure must be zero. If this date is specified, the StandardDate value in the TimeZoneInformation structure must also be specified. Otherwise, the system assumes the time zone data is invalid and no changes will be applied.

.

        public SystemTime daylightDate;

.
Summary
.

static extern bool SystemTimeToFileTime([In] IntPtr lpSystemTime,

.

public static DateTime SytemTimeToDateTime(ref SYSTEMTIME st)

.

    //malloc the SystemTime structure

.

    IntPtr pSystemTime = Marshal.AllocHGlobal(stLen);

.

    // copy SystemTime structure to the global heap

.

    Marshal.StructureToPtr(st, pSystemTime, true);

.

    SystemTimeToFileTime(pSystemTime, pFileTime);

.

    Marshal.FreeHGlobal(pSystemTime);

.
Documentation
[SystemTimeToFileTime] on MSDN
.
Summary
.

static extern bool SystemTimeToTzSpecificLocalTime(IntPtr

.

   lpTimeZoneInformation, [In] ref SYSTEMTIME lpUniversalTime,

.

   out SYSTEMTIME lpLocalTime);

.

Friend Shared Function SystemTimeToTzSpecificLocalTime( _

.

                 <[In]()> ByRef lpUniversalTime As SYSTEMTIME, _

.

                 <Out()> ByRef lpLocalTime As SYSTEMTIME) _

.
Documentation
[SystemTimeToTzSpecificLocalTime] on MSDN

irprops

.

        Public lastSeen As SystemTime

.

        Public lastUsed As SystemTime

.

            Me.lastSeen = New SystemTime

.

            Me.lastUsed = New SystemTime

.

    Private Structure SystemTime

ntdll

.

public static extern uint NtQuerySystemTime(out long SystemTime);

.

Declare Function NtQuerySystemTime Lib "ntdll.dll" (Currency) As TODO

.

NtQuerySystemTime(out t);

.
Documentation
[NtQuerySystemTime] on MSDN
.

    SystemTimeOfDayInformation = 0x0003,

.

    SystemTimeAdjustmentInformation = 0x001C,

.

    SystemTimeSlipNotification = 0x002E,

.

    SystemTimeZoneInformation = 0x005D,

winspool

.

    Public Submitted As SYSTEMTIME

.

    <StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Auto)> Structure SYSTEMTIME

winmm

.

static extern UInt32 timeGetSystemTime( ref MmTime mmTime, UInt32 sizeMmTime );

.

Declare Function timeGetSystemTime Lib "winmm.dll" (TODO) As TODO

.
Documentation
[timeGetSystemTime] on MSDN

coredll

.

       (ByVal AppName As String, ByRef ExecTime As SYSTEMTIME) As Boolean

.

    Public Structure SYSTEMTIME

.

In VB, function will return "true" if successful when adding app to run. However, it returns a "false" when cancelling the app even though the event is successfully cancelled. I'm guessing this is due to the systemtime structure being passed by reference and in this case references nothing. See sample code below. (VB .NET CF)

.

    Dim wakeuptime As SYSTEMTIME

.

    'populate systemtime structure with our new date

.

SYSTEMTIME

.

  notificationTrigger.StartTime = new SYSTEMTIME( dt );

.

  notificationTrigger.EndTime = new SYSTEMTIME();

.

SYSTEMTIME

.

  notificationTrigger.StartTime = new SYSTEMTIME( dt );

.

  notificationTrigger.EndTime = new SYSTEMTIME();

.

    public SYSTEMTIME StartTime;

.

    public SYSTEMTIME EndTime;

.

SYSTEMTIME

.

   static extern bool SetLocalTime(ref SYSTEMTIME lpSystemTime);

.

   Private Shared Function SetLocalTime(ByRef time As SYSTEMTIME) As Boolean

.

public struct SYSTEMTIME

.

Private Structure SYSTEMTIME

.

To set the date and time without consideration to the locale settings use SetSystemTime.

.

static void SetSystemTime(System.DateTime dt)

.

     SYSTEMTIME time2;

.

To see sample code for VB, please go to SetSystemTime.

.

   static extern bool SetSystemTime(ref SYSTEMTIME time);

.

   Private Shared Function SetSystemTime(ByRef time As SYSTEMTIME) As Boolean

.

public struct SYSTEMTIME

.

Private Structure SYSTEMTIME

.

    Private Structure SYSTEMTIME

.

    Private Shared Function SetSystemTime(ByRef time As SYSTEMTIME) As Boolean

.

    Dim s As New SYSTEMTIME

.

    SetSystemTime(s)

.

     private struct SYSTEMTIME

.

     private static extern bool SetSystemTime(ref SYSTEMTIME time);

.

    SYSTEMTIME s = new SYSTEMTIME();

.

     SetSystemTime(ref s);

.
Documentation
[SetSystemTime] on MSDN
.

Declare Sub SystemTimerReset Lib "coredll.dll" Alias "SystemIdleTimerReset" ()

.
Summary
.

[DllImport("kernel32.dll", EntryPoint = "SystemTimeToFileTime", SetLastError = true)]

.

    public static extern bool SystemTimeToFileTime(ref SYSTEMTIME lpSystemTime, ref FILETIME lpFileTime);

.

Declare Function SystemTimeToFileTime Lib "Coredll.dll" (TODO) As TODO

.

SystemTime and FileTime

.

private static DateTime SystemTimeToDateTime(ref SYSTEMTIME st)

.

        SystemTimeToFileTime(ref st, out ft);

.
Documentation
[SystemTimeToFileTime] on MSDN

Structures

.

        public SYSTEMTIME stLastSeen;

.

        public SYSTEMTIME stLastUsed;

.

SYSTEMTIME

.

    public SystemTime StandardDate;

.

    public SystemTime DaylightDate;

.

Actually, this is NOT working. The only solution I've found so far is using the API Kernel32.dll function FileTimeToSystemTime, then transforming from that into a regular DateTime.

.

   public SYSTEMTIME Submitted;

.

private struct SYSTEMTIME {

.

  public SYSTEMTIME( DateTime dt )

.

    dt = dt.ToUniversalTime();  // SetSystemTime expects the SYSTEMTIME in UTC

.

Private Structure SYSTEMTIME

.

internal struct SystemTime

.

   public SystemTime(DateTime dt)

.

   public SystemTime(ushort year, ushort month, ushort day, ushort hour = 0, ushort minute = 0, ushort second = 0, ushort millisecond = 0)

.

   public static implicit operator DateTime(SystemTime st)

.

   public static bool operator ==(SystemTime s1, SystemTime s2)

.

   public static bool operator !=(SystemTime s1, SystemTime s2)

.

   public static readonly SystemTime MinValue, MaxValue;

.

   static SystemTime()

.

      MinValue = new SystemTime(1601, 1, 1);

.

      MaxValue = new SystemTime(30827, 12, 31, 23, 59, 59, 999);

.

      if (obj is SystemTime)

.

     return ((SystemTime)obj) == this;

.
Documentation
[SYSTEMTIME] on MSDN
.

    public SYSTEMTIME StandardDate;

.

    public SYSTEMTIME DaylightDate;  

.

    Public StandardDate As SYSTEMTIME

.

    Public DaylightDate As SYSTEMTIME

.

SYSTEMTIME

.

See also: http://www.pinvoke.net/default.aspx/Structures.SYSTEMTIME

advapi32

.

        case SecurityEntity.SE_SYSTEMTIME_NAME:

.

           return "SeSystemtimePrivilege";

.

      SE_SYSTEMTIME_NAME,

.

public const string SE_SYSTEMTIME_NAME = "SeSystemtimePrivilege";

Interfaces

.

    int GetRunTimes(                    ref SYSTEMTIME pstBegin,

.

                                ref SYSTEMTIME pstEnd,

.

                                out SYSTEMTIME rgstTaskTimes);

.

    int GetNextRunTime(                     ref SYSTEMTIME pstNextRun);

.

    int GetMostRecentRunTime(                   out SYSTEMTIME pstLastRun);


 
Access PInvoke.net directly from VS: