Public Class Class1
<StructLayout(LayoutKind.Sequential)> _
Private Structure SYSTEMTIME
<MarshalAs(UnmanagedType.U2)> Public Year As Short
<MarshalAs(UnmanagedType.U2)> Public Month As Short
<MarshalAs(UnmanagedType.U2)> Public DayOfWeek As Short
<MarshalAs(UnmanagedType.U2)> Public Day As Short
<MarshalAs(UnmanagedType.U2)> Public Hour As Short
<MarshalAs(UnmanagedType.U2)> Public Minute As Short
<MarshalAs(UnmanagedType.U2)> Public Second As Short
<MarshalAs(UnmanagedType.U2)> Public Milliseconds As Short
End Structure
<DllImport("kernel32.dll")> _
Private Shared Sub GetLocalTime(ByRef time As SYSTEMTIME)
End Sub
Public Sub test1()
Dim currenttime As SYSTEMTIME
GetLocalTime(currenttime)
Console.WriteLine("day: {0}", currenttime.Day)
Console.WriteLine("dayofweek: {0}", currenttime.DayOfWeek)
Console.WriteLine("month: {0}", currenttime.Month)
Console.WriteLine("year: {0}", currenttime.Year)
Console.WriteLine("hour: {0}", currenttime.Hour)
Console.WriteLine("minute: {0}", currenttime.Minute)
Console.WriteLine("second: {0}", currenttime.Second)
Console.WriteLine("milliseconds: {0}", currenttime.Milliseconds)
End Sub
End Class
Alternative Managed API:
Do you know one? Please contribute it!
System.DateTime.Now
Retrieves the current system date and time. The system time is expressed in Coordinated Universal Time (UTC).
2/26/2008 9:03:50 PM - -64.16.11.250
Represents a date and time using individual members for the month, day, year, weekday, hour, minute, second, and millisecond.
4/17/2012 9:12:16 PM - dahall-65.129.36.108
Please edit this page!
Do you have...
helpful tips or sample code to share for using this API in managed code?
corrections to the existing content?
variations of the signature you want to share?
additional languages you want to include?
Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).