using System.Runtime.InteropServices;   //使用DllImport
public partial class Form1 : Form
        static extern void GetSystemTime(out SYSTEMTIME lpSystemTime);
        private struct SYSTEMTIME
            public ushort wYear;
            public ushort wMonth;
            public ushort wDayOfWeek;
            public ushort wDay;
            public ushort wHour;
            public ushort wMinute;
            public ushort wSecond;
            public ushort wMilliseconds;
        private void GetTime()
            // Call the native GetSystemTime method
            // with the defined structure.
            SYSTEMTIME stime = new SYSTEMTIME();
            GetSystemTime(out stime);
            // Show the current time.           
            MessageBox.Show("Current Time: " +
                stime.wHour.ToString() + ":"
                + stime.wMinute.ToString());



    Frank 發表在 痞客邦 留言(0) 人氣()