当前位置: 首页>>代码示例>>C#>>正文


C# SYSTEMTIME类代码示例

本文整理汇总了C#中SYSTEMTIME的典型用法代码示例。如果您正苦于以下问题:C# SYSTEMTIME类的具体用法?C# SYSTEMTIME怎么用?C# SYSTEMTIME使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SYSTEMTIME类属于命名空间,在下文中一共展示了SYSTEMTIME类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetTime

 private void GetTime()
 {
     SYSTEMTIME stime = new SYSTEMTIME();
     GetSystemTime(out stime);
     //labTime.Text = "Current Time:" + stime.wYear.ToString() + "/" + stime.wMonth.ToString() + "/" + stime.wDay.ToString() + "  " + stime.wHour.ToString() +":"+ stime.wMinute.ToString() +":"+ stime.wSecond.ToString();
     //lblError.Text = DateTime.Now.ToString("yyyyMMdd");
 }
开发者ID:yan1106,项目名称:Phase2_Project_20160625_ver.final,代码行数:7,代码来源:Login.aspx.cs

示例2: Main

        static void Main(string[] args)
        {
            TIME_ZONE_INFORMATION tz = new TIME_ZONE_INFORMATION();
            GetTimeZoneInformation(ref tz);

            string s = args[0];
            System.Globalization.DateTimeFormatInfo dtfi =
                new System.Globalization.DateTimeFormatInfo();
            dtfi.FullDateTimePattern = "dd/MM/yyyy HH:mm:ss zz";
            dtfi.DateSeparator = "/";
            dtfi.TimeSeparator = ":";
            DateTime dt =
                DateTime.Parse(s, dtfi);

            
            SYSTEMTIME time = new SYSTEMTIME(dt);
            //time.wDay = (ushort)dt.Day;
            //time.wHour = (ushort)dt.Hour;
            //time.wDayOfWeek = (ushort)dt.DayOfWeek;
            //time.wMilliseconds = (ushort)dt.Millisecond;
            //time.wMinute = (ushort)dt.Minute;
            //time.wMonth = (ushort)dt.Month;
            //time.wSecond = (ushort)dt.Second;
            //time.wYear = (ushort)dt.Year;

            SetSystemTime(ref time);
        }
开发者ID:ramilexe,项目名称:tsdfamilia,代码行数:27,代码来源:Program.cs

示例3: Main

        private static void Main(string[] args)
        {
            if (args.Length == 5)
            {
                var time = new SYSTEMTIME
                               {
                                   wDay = ushort.Parse(args[0]),
                                   wMonth = ushort.Parse(args[1]),
                                   wYear = ushort.Parse(args[2]),
                                   wHour = ushort.Parse(args[3]),
                                   wMinute = ushort.Parse(args[4])
                               };
                SetTime(time);
                return;
            }
            if (File.Exists("date.txt"))
            {

                var tr = new StreamReader("date.txt");
                string dateString = tr.ReadLine();
                if (dateString != null)
                {
                    dateString = dateString.Trim();
                    DateTime convertedDate = DateTime.Parse(dateString);
                    SetTime(convertedDate);
                }
            }
            else
            {
                SetTime(1, 1, 2012, 12, 00);
            }
        }
开发者ID:maxisoft,项目名称:BackInTime,代码行数:32,代码来源:Program.cs

示例4: Main

        static void Main(string[] args)
        {
            if (args.Length == 0 || (new string[] { "help", "--help", "/?" }).Contains(args[0]))
            {
                System.Console.WriteLine("Give as the only parameter the time difference in hours. For example \"SetClock.exe -2\" moves the clock two hours backwards.");
                return;
            }

            double delta = 0;
            try
            {
                delta = Convert.ToDouble(args[0]);
            }
            catch
            {
                System.Console.WriteLine("Error converting input parameter to time difference.");
                return;
            }

            var newDateTime = DateTime.Now.ToUniversalTime().AddHours(delta);
            var newSystemTime = new SYSTEMTIME();
            newSystemTime.wYear = Convert.ToInt16(newDateTime.Year);
            newSystemTime.wMonth = Convert.ToInt16(newDateTime.Month);
            newSystemTime.wDay = Convert.ToInt16(newDateTime.Day);
            newSystemTime.wDayOfWeek = Convert.ToInt16(newDateTime.DayOfWeek);
            newSystemTime.wHour = Convert.ToInt16(newDateTime.Hour);
            newSystemTime.wMinute = Convert.ToInt16(newDateTime.Minute);
            newSystemTime.wSecond = Convert.ToInt16(newDateTime.Second);
            newSystemTime.wMilliseconds = Convert.ToInt16(newDateTime.Millisecond);

            SetSystemTime(ref newSystemTime);
        }
开发者ID:ohel,项目名称:setclock,代码行数:32,代码来源:Program.cs

示例5: SetTime

 public static void SetTime(SYSTEMTIME time)
 {
     if (!SetLocalTime(ref time))
     {
         // The native function call failed, so throw an exception
         throw new Win32Exception(Marshal.GetLastWin32Error());
     }
 }
开发者ID:maxisoft,项目名称:BackInTime,代码行数:8,代码来源:Program.cs

示例6: ChangeDateDown

 private void ChangeDateDown(int numDays)
 {
     DateTime t = DateTime.Now.AddDays(-1);
     DateTime h = DateTime.Now.AddHours(0);
     SYSTEMTIME st = new SYSTEMTIME();
     st.FromDateTime(t);
     SetSystemTime(ref st);
 }
开发者ID:jsondotbower,项目名称:C-Apps,代码行数:8,代码来源:Form1.cs

示例7: GetTime

        /// <summary>
        /// Gets current system time.
        /// </summary>
        /// <returns></returns>
        public static DateTime GetTime()
        {
            // Call the native GetSystemTime method
            // with the defined structure.
            SYSTEMTIME stime = new SYSTEMTIME();
            GetSystemTime(ref stime);

            var utc = new DateTime(stime.wYear, stime.wMonth, stime.wDay, stime.wHour, stime.wMinute, stime.wSecond, stime.wMilliseconds, DateTimeKind.Utc);
            return utc.ToLocalTime();
        }
开发者ID:NikolaR,项目名称:Convenience,代码行数:14,代码来源:SystemTime.cs

示例8: SetSystemTime

        // SYSTEMTIME�\����
        //
        // ABSTRACT	: DateTime�R���g���[���Ƀ��b�Z�[�W�𑗂�
        //
        public static System.IntPtr SetSystemTime(
			int				pid			, // �^�[�Q�b�g�̃v���Z�XID
			System.IntPtr	hDateTime	, // DATETIME�R���g���[���n���h��
			SYSTEMTIME		sysTime		)
        {
            System.IntPtr	hAccess;
            System.IntPtr	mem;
            System.IntPtr	result;
            GCHandle		gctemp;
            int				n;

            hAccess = InterProcess.OpenProcess(
                InterProcess.PROCESS_VM_OPERATION	|
                InterProcess.PROCESS_VM_READ		|
                InterProcess.PROCESS_VM_WRITE		,
                0									,
                pid									);

            mem = InterProcess.VirtualAllocEx(
                hAccess						,
                (System.IntPtr)0			,
                4096						,
                InterProcess.MEM_COMMIT		|
                InterProcess.MEM_RESERVE	,
                InterProcess.PAGE_READWRITE	);

            // �\���̂𑊎�v���Z�X�ɏ�������

            gctemp = GCHandle.Alloc( sysTime, GCHandleType.Pinned );

            System.IntPtr a = gctemp.AddrOfPinnedObject();

            InterProcess.WriteProcessMemory(
                hAccess					,
                mem						,
                a						,
                Marshal.SizeOf( sysTime ),
                out n					);

            result = Window.SendMessage(
                hDateTime			,
                DTM_SETSYSTEMTIME	,
                System.IntPtr.Zero	,		// GDT_VALID
                mem					);

            gctemp.Free();

            InterProcess.VirtualFreeEx( hAccess, mem, 4096, InterProcess.MEM_RELEASE );

            return result;
        }
开发者ID:ozeppi,项目名称:mAgicAnime,代码行数:55,代码来源:User32API.cs

示例9: SetLocalTime

        public static void SetLocalTime(DateTime time)
        {
            var newTime = new SYSTEMTIME
            {
                wYear = (ushort)time.Year,
                wMonth = (ushort)time.Month,
                wDay = (ushort)time.Day,
                wHour = (ushort)time.Hour,
                wMinute = (ushort)time.Minute,
                wSecond = (ushort)time.Second,
                wMilliseconds = (ushort)time.Millisecond
            };

            SetLocalTime(ref newTime);
        }
开发者ID:c0d3m0nky,项目名称:mty,代码行数:15,代码来源:SystemTimeHelper.cs

示例10: SetTime

 /// <summary>
 /// Sets current system time.
 /// </summary>
 /// <param name="dateTime">Time to set as current system time.</param>
 public static void SetTime(DateTime dateTime)
 {
     dateTime = dateTime.ToUniversalTime();
     SYSTEMTIME stime = new SYSTEMTIME()
     {
         wYear = (ushort)dateTime.Year,
         wMonth = (ushort)dateTime.Month,
         wDay = (ushort)dateTime.Day,
         wHour = (ushort)dateTime.Hour,
         wMinute = (ushort)dateTime.Minute,
         wSecond = (ushort)dateTime.Second,
         wMilliseconds = (ushort)dateTime.Millisecond
     };
     SetSystemTime(ref stime);
 }
开发者ID:NikolaR,项目名称:Convenience,代码行数:19,代码来源:SystemTime.cs

示例11: SetTime

	///<summary>Set the windows system time.</summary>
	public static void SetTime(DateTime newTime) {
		// Call the native SetLocalTime method 
		// with the defined structure.
		SYSTEMTIME systime=new SYSTEMTIME();
		systime.wYear=(ushort)newTime.Year;
		systime.wMonth=(ushort)newTime.Month;
		systime.wDayOfWeek=(ushort)newTime.DayOfWeek;
		systime.wDay=(ushort)newTime.Day;
		systime.wHour=(ushort)newTime.Hour;
		systime.wMinute=(ushort)newTime.Minute;
		systime.wSecond=(ushort)newTime.Second;
		systime.wMilliseconds=(ushort)newTime.Millisecond;
		SetLocalTime(ref systime);
		string messageText="System date and time set to:  "+newTime.ToString("MM/dd/yyyy hh:mm:ss.fff tt")+".";
		EventLog.WriteEntry("OpenDental",messageText,EventLogEntryType.Information);
	}
开发者ID:romeroyonatan,项目名称:opendental,代码行数:17,代码来源:WindowsTime.cs

示例12: DigitalClockDisplay

	public DigitalClockDisplay(bool is24Hour, bool suppressExtra)
	{
        f24Hour = is24Hour;
		fSuppress = suppressExtra;
		fSegmentedNumber = new SegmentedNumber();

        ptColon = new Point[2][];
        ptColon[0] = new Point[] { new Point(2, 21), new Point(6, 17), new Point(10, 21), new Point(6, 25) };
        ptColon[1] = new Point[] { new Point(2, 51), new Point(6, 47), new Point(10, 51), new Point(6, 55) };

        fcolonPolies = new PolygonG[2];
        fcolonPolies[0] = new PolygonG(ptColon[0]);
        fcolonPolies[1] = new PolygonG(ptColon[1]);

        fLastTime = new SYSTEMTIME();
        fThisTime = new SYSTEMTIME();
    }
开发者ID:Wiladams,项目名称:NewTOAPIA,代码行数:17,代码来源:DigitalClockDisplay.cs

示例13: SetTime

 public static void SetTime(DateTime dt)
 {
     // Call the native GetSystemTime method
     // with the defined structure.
     SYSTEMTIME systime = new SYSTEMTIME();
     //GetSystemTime(ref systime);
     systime.wDay = (ushort)dt.Day;
     systime.wMonth = (ushort)dt.Month;
     systime.wYear = (ushort)dt.Year;
     systime.wHour = (ushort)dt.Hour;
     systime.wMinute = (ushort)dt.Minute;
     systime.wSecond = (ushort)dt.Second;
     // Set the system clock ahead one hour.
     //systime.wHour = (ushort)(systime.wHour + 1 % 24);
     SetSystemTime(ref systime);
     System.Diagnostics.Debug.WriteLine(string.Format("New time: " + systime.wHour.ToString() + ":"
         + systime.wMinute.ToString()+"\r\n"));
 }
开发者ID:andrejpanic,项目名称:win-mobile-code,代码行数:18,代码来源:SystemTime.cs

示例14: BLUETOOTH_DEVICE_INFO

        public BLUETOOTH_DEVICE_INFO(long address)
        {
            dwSize = 560;
            this.Address = address;
            ulClassofDevice = 0;
            fConnected = false;
            fRemembered = false;
            fAuthenticated = false;
#if WinXP
            stLastSeen = new SYSTEMTIME();
            stLastUsed = new SYSTEMTIME();

            // The size is much smaller on CE (no times and string not inline) it
            // appears to ignore the bad dwSize value.  So don't check this on CF.
            System.Diagnostics.Debug.Assert(Marshal.SizeOf(typeof(BLUETOOTH_DEVICE_INFO)) == dwSize, "BLUETOOTH_DEVICE_INFO SizeOf == dwSize");
#endif
            szName = "";
        }
开发者ID:intille,项目名称:mitessoftware,代码行数:18,代码来源:BLUETOOTH_DEVICE_INFO.cs

示例15:

        int IVsSolutionEventsProjectUpgrade.OnAfterUpgradeProject(IVsHierarchy pHierarchy, uint fUpgradeFlag, string bstrCopyLocation, SYSTEMTIME stUpgradeTime, IVsUpgradeLogger pLogger)
        {
            Debug.Assert(pHierarchy != null);

            Project upgradedProject = VsUtility.GetProjectFromHierarchy(pHierarchy);

            if (upgradedProject != null)
            {
                IList<IPackage> packagesToBeReinstalled = ProjectRetargetingUtility.GetPackagesToBeReinstalled(upgradedProject);

                if (!packagesToBeReinstalled.IsEmpty())
                {
                    pLogger.LogMessage((int)__VSUL_ERRORLEVEL.VSUL_ERROR, upgradedProject.Name, upgradedProject.Name,
                        String.Format(CultureInfo.CurrentCulture, Resources.ProjectUpgradeAndRetargetErrorMessage, String.Join(", ", packagesToBeReinstalled.Select(p => p.Id))));
                }
            }
            return VSConstants.S_OK;
        }
开发者ID:Newtopian,项目名称:nuget,代码行数:18,代码来源:ProjectUpgradeHandler.cs


注:本文中的SYSTEMTIME类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。