public static void Main() { try { MySystemTime sysTime = new MySystemTime(); NativeMethods.GetSystemTime(sysTime); Console.WriteLine("The System time is {0}/{1}/{2} {3}:{4}:{5}", sysTime.wDay, sysTime.wMonth, sysTime.wYear, sysTime.wHour, sysTime.wMinute, sysTime.wSecond); } catch (TypeLoadException e) { Console.WriteLine("TypeLoadException : " + e.Message); } catch (Exception e) { Console.WriteLine("Exception : " + e.Message); } }
internal static extern void GetSystemTime([MarshalAs(UnmanagedType.LPStruct)] MySystemTime st);