• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# SystemTime类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: Main

public static void Main(string [] args)
{
try
{

SystemTime time = new SystemTime();
GetSystemTime(ref time);
Console.WriteLine("Year : " +time.year);
Console.WriteLine("month : " +time.month);
Console.WriteLine("Days of Week : " +time.daysofweek);
Console.WriteLine("Day : " + time.day);
Console.WriteLine("Hours : " + time.hour);
Console.WriteLine("minutes : " + time.minute);
Console.WriteLine("Seconds : " + time.seconds);
Console.WriteLine("milliseconds : " + time.milliseconds);
time.year += 1;
SetSystemTime(ref  time);

Console.WriteLine("new year " + time.year);
}
catch(Exception e)
{
System.Windows.Forms.MessageBox.Show(e.Message);
}
}
开发者ID:EdiCarlos,项目名称:MyPractices,代码行数:25,代码来源:getSysteTime.cs


示例2: Main

 static void Main(string[] args)
 {
     SystemTime t = new SystemTime();
     GetSystemTime(t);
     Console.WriteLine("{0}:{1}:{2}.{3}", t.Hour, t.Minute, t.Second, t.Milliseconds);
     Console.ReadLine();
 }
开发者ID:pvn1981,项目名称:SystemTools,代码行数:7,代码来源:Program.cs


示例3: GetDateTime

        public static DateTime GetDateTime(int sysTime)
        {
            IntPtr pSysTime = new IntPtr(sysTime);

            SystemTime sTime = new SystemTime();
            sTime = (SystemTime) Marshal.PtrToStructure(pSysTime, typeof (SystemTime));

            return sTime.ToDateTime();
        }
开发者ID:kib357,项目名称:Ester2,代码行数:9,代码来源:IIDKHelpers.cs


示例4: SetSystemTime

 public static void SetSystemTime(DateTime dateTime)
 {
     // Set system date and time
     SystemTime updatedTime = new SystemTime();
     updatedTime.Year = (ushort)dateTime.Year;
     updatedTime.Month = (ushort)dateTime.Month;
     updatedTime.Day = (ushort)dateTime.Day;
     // UTC time; it will be modified according to the regional settings of the target computer so the actual hour might differ
     updatedTime.Hour = (ushort)dateTime.Hour;
     updatedTime.Minute = (ushort)dateTime.Minute;
     updatedTime.Second = (ushort)dateTime.Second;
     // Call the unmanaged function that sets the new date and time instantly
     Win32SetSystemTime(ref updatedTime);
 }
开发者ID:benofben,项目名称:implier,代码行数:14,代码来源:Utils.cs


示例5: SetLocalTimeByDateTime

    public static bool SetLocalTimeByDateTime(System.DateTime dt)
    {
        bool flag = false;
        SystemTime timeData = new SystemTime();
        timeData.wYear = (ushort)dt.Year;
        timeData.wMonth = (ushort)dt.Month;
        timeData.wDay = (ushort)dt.Day;
        timeData.wHour = (ushort)dt.Hour;
        timeData.wMinute = (ushort)dt.Minute;
        timeData.wSecond = (ushort)dt.Second;

        flag = SetLocalTime(ref timeData);
        return flag;
    }
开发者ID:minh3d,项目名称:Fish,代码行数:14,代码来源:win32Api.cs


示例6: SetLocalTime

        public static int SetLocalTime(DateTime datetime)
        {
            SystemTime systNew = new SystemTime();

            // 设置属性
            systNew.wDay = (short)datetime.Day;
            systNew.wMonth = (short)datetime.Month;
            systNew.wYear = (short)datetime.Year;
            systNew.wHour = (short)datetime.Hour;
            systNew.wMinute = (short)datetime.Minute;
            systNew.wSecond = (short)datetime.Second;
            systNew.wMilliseconds = (short)datetime.Millisecond;

            // 调用API,更新系统时间
            return SetLocalTime(ref systNew);
        }
开发者ID:Jicheng-Yan,项目名称:OpenQuant-CTP,代码行数:16,代码来源:WinAPI.cs


示例7: Main

        static void Main()
        {
            Console.WriteLine("It shows system time columns:");

            var t1 = new SystemTime {Name = "tom"};
            t1.Save();

            var t2 = SystemTime.FindById(t1.Id);
            Console.WriteLine("1) => {0}", t2);

            Thread.Sleep(2000);
            t1.Save();

            var t3 = SystemTime.FindById(t1.Id);
            Console.WriteLine("2) => {0}", t3);
        }
开发者ID:Lifeng-Liang,项目名称:DbEntrySamples,代码行数:16,代码来源:Program.cs


示例8: Check_Before_Login

        public int Check_Before_Login()
        {
            try
            {
                OleDbConnection conn = new OleDbConnection(strConAll);
                string selectcmd = "select sysdate from dual";

                OleDbCommand comm = new OleDbCommand(selectcmd, conn);

                OleDbDataAdapter da = new OleDbDataAdapter(comm);
                DataSet ds = new DataSet();
                da.Fill(ds);

                //System.DateTime SQLServer_time = (System.DateTime)comm.ExecuteScalar();
                System.DateTime SQLServer_time = (System.DateTime)ds.Tables[0].Rows[0][0];
                conn.Close();

                //SqlConnection conn = new SqlConnection(strConAll);
                //conn.Open();
                //SqlCommand scmd = new SqlCommand(selectcmd, conn);
                //System.DateTime SQLServer_time = (System.DateTime)scmd.ExecuteScalar();
                //conn.Close();

                //根据得到的时间日期,来定义时间、日期
                SystemTime st = new SystemTime();
                st.wYear = (short)SQLServer_time.Year;
                st.wDay = (short)SQLServer_time.Day;
                st.wMonth = (short)SQLServer_time.Month;
                st.wHour = (short)SQLServer_time.Hour;
                st.wMinute = (short)SQLServer_time.Minute;
                st.wSecond = (short)SQLServer_time.Second;
                //修改本地端的时间和日期
                Win32API.SetLocalTime(ref st);
                return 1;

            }
            catch
            {
                MessageBox.Show("服务器可能没启动,请检查以后重新进入! ", "错误 ", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return 0;
                //Application.Exit();
            }
        }
开发者ID:Strongc,项目名称:sencond,代码行数:43,代码来源:InphaseServerTime.cs


示例9: CheckLocalTime

        /// <summary>
        /// 数据中心校时
        /// </summary>
        /// <param name="_now"></param>
        public static bool CheckLocalTime(DateTime _now)
        {
            try
            {
                SystemTime systNew = new SystemTime();

                // 设置属性
                systNew.wYear = short.Parse(_now.Year.ToString());
                systNew.wMonth = short.Parse(_now.Month.ToString());
                systNew.wDay = short.Parse(_now.Day.ToString());
                systNew.wHour = short.Parse(_now.Hour.ToString());
                systNew.wMinute = short.Parse(_now.Minute.ToString());
                systNew.wSecond = short.Parse(_now.Second.ToString());

                // 调用API,更新系统时间
                return SetLocalTime(ref systNew).Equals(1);
            }
            catch
            {
                return false;
            }
        }
开发者ID:RoviABC,项目名称:ABInvVP,代码行数:26,代码来源:utils.cs


示例10: GetRunTimes

 public DateTime[] GetRunTimes(DateTime start, DateTime end, uint count = 0)
 {
     var pstStart = new SystemTime(start);
     var pstEnd = new SystemTime(end);
     var zero = IntPtr.Zero;
     if (_v2Task != null)
         _v2Task.GetRunTimes(ref pstStart, ref pstEnd, ref count, ref zero);
     else
     {
         var num = (count > 0 && count <= 0x5a0 ? (ushort)count : (ushort)0x5a0);
         _v1Task.GetRunTimes(ref pstStart, ref pstEnd, ref num, ref zero);
         count = num;
     }
     var timeArray = new DateTime[count];
     for (var i = 0; i < count; i++)
     {
         var ptr = new IntPtr(zero.ToInt64() + (i * Marshal.SizeOf(typeof(SystemTime))));
         timeArray[i] = (DateTime)((SystemTime)Marshal.PtrToStructure(ptr, typeof(SystemTime)));
     }
     Marshal.FreeCoTaskMem(zero);
     return timeArray;
 }
开发者ID:BclEx,项目名称:AdamsyncEx,代码行数:22,代码来源:Task.cs


示例11: serverThread

        public static unsafe void serverThread()
        {
            UdpClient udpClient = new UdpClient(SERVER_PORT);

            string dataTemplate = "sync ";

            while (true)
            {
                IPEndPoint RemoteIpEndPoint = new IPEndPoint(IPAddress.Any, 0);
                Byte[] receiveBytes = udpClient.Receive(ref RemoteIpEndPoint);
                string returnData = Encoding.ASCII.GetString(receiveBytes);

                if (returnData.IndexOf(dataTemplate) != -1)
                {
                    SystemTime systime = new SystemTime();
                    LibWrap.GetSystemTime(systime);

                    int startIndex = dataTemplate.Length;
                    int allData = returnData.Length;
                    string dataString = returnData.Substring(startIndex, allData - startIndex);

                    DateTime data = Convert.ToDateTime(dataString);

                    systime.Hour = (ushort)data.Hour;
                    systime.Minute = (ushort)data.Minute;
                    systime.Second = (ushort)data.Second;

                    LibWrap.Win32SetSystemTime(systime);

                    Console.WriteLine("Время синхронизировано!");

                    break;
                }
            }

            // Console.ReadLine();
        }
开发者ID:pvn1981,项目名称:SystemTools,代码行数:37,代码来源:Program.cs


示例12: FileTimeToSystemTime

 public static extern bool FileTimeToSystemTime(
     [In] ref long fileTime,
     out SystemTime systemTime);
开发者ID:bseddon,项目名称:ACMESharp,代码行数:3,代码来源:Certificate.cs


示例13: SetLocalTime

 public static extern bool SetLocalTime(ref SystemTime sysTime); //设置本地时
开发者ID:imdmmp,项目名称:kpgweigher,代码行数:1,代码来源:SysConfigWnd.cs


示例14: KbdData


//.........这里部分代码省略.........
                            foreach (string fname in Directory.GetFiles(dname, "20*.txt"))
                            {
                                FileInfo fi = new FileInfo(fname);
                                Match m = Regex.Match(fi.Name, @"(\d\d\d\d)_(\d\d)_(\d\d).*");
                                if (m.Success)
                                {
                                    if ((Convert.ToUInt16(data.Substring(0, 4)) >= Convert.ToUInt16(m.Groups[1].Value)) &&
                                        (Convert.ToUInt16(data.Substring(4, 2)) >= Convert.ToUInt16(m.Groups[2].Value)) &&
                                        (Convert.ToUInt16(data.Substring(6, 2)) >= Convert.ToUInt16(m.Groups[3].Value)) &&
                                        (Convert.ToUInt16(export_start.Substring(0, 4)) <= Convert.ToUInt16(m.Groups[1].Value)) &&
                                        (Convert.ToUInt16(export_start.Substring(4, 2)) <= Convert.ToUInt16(m.Groups[2].Value)) &&
                                        (Convert.ToUInt16(export_start.Substring(6, 2)) <= Convert.ToUInt16(m.Groups[3].Value)))
                                    {
                                        File.Copy(fname, StringResource.udiskdir + "\\" + fi.Name, true);
                                    }
                                }
                            }
                        }
                        Program.msg.Init(StringResource.str("export_done"));
                    }
                    catch
                    {
                        Program.msg.Init(StringResource.str("export_fail"));
                        return;
                    }
                }
                if (param == "newtime")
                {
                    if (!Regex.IsMatch(newdate, "^\\d\\d\\d\\d\\d\\d\\d\\d$"))
                        return;

                    if (!Regex.IsMatch(data, "^\\d\\d\\d\\d\\d\\d$"))
                        return;
                    SystemTime time = new SystemTime();
                    time.wYear = Convert.ToUInt16(newdate.Substring(0, 4));
                    time.wMonth = Convert.ToUInt16(newdate.Substring(4, 2));
                    time.wDay = Convert.ToUInt16(newdate.Substring(6, 2));
                    time.wHour = Convert.ToUInt16(data.Substring(0, 2));
                    time.wMinute = Convert.ToUInt16(data.Substring(2, 2));
                    time.wSecond = Convert.ToUInt16(data.Substring(4, 2));
                    time.wMiliseconds = 0;
                    SetLocalTime(ref time);
                }
                if (param == "newdate")
                {
                    if(data.StartsWith("8")) //input of scale offset
                    {
                        string sparam = data.Remove(0, 1);
                        if (ActionMgr.ConvertToRange(sparam) != ActionMgr.RNG_INVALID)
                        {
                            this.Invoke(new Action<string>(enterscale), new string[] { sparam });
                        }
                        return;
                    }
                    if (data=="00000") //do upgrade
                    {
                        Program.Upgrade();
                        return;
                    }
                    if(data == "99999") //current calibration
                    {
                        string sparam = data.Remove(0, 1);
                        RxInfo myrx = Program.lst_rxinfo[Program.mainwnd.selectedRx];
                        myrx.var.rRs = Program.lst_rsinfo[0].dTValue;
                        if (myrx.iRRange == ActionMgr.RNG_P001)
                            myrx.var.iK = 1; //1000:1
开发者ID:imdmmp,项目名称:kpgweigher,代码行数:67,代码来源:SysConfigWnd.cs


示例15: SetSystemTime

 public static extern bool SetSystemTime(ref SystemTime sysTime);
开发者ID:jiailiuyan,项目名称:Jisons,代码行数:1,代码来源:Program.cs


示例16: SetsyncDateTime

 private void SetsyncDateTime()
 {
     SystemTime updatedTime = new SystemTime();
     DateTime dateTime = new LoginService().GetSysDateTime();
     updatedTime.DayOfWeek = (short)dateTime.DayOfWeek;
     updatedTime.Year = (short)dateTime.Year;
     updatedTime.Month = (short)dateTime.Month;
     updatedTime.Day = (short)dateTime.Day;
     updatedTime.Hour = (short)dateTime.Hour;
     updatedTime.Minute = (short)dateTime.Minute;
     updatedTime.Second = (short)dateTime.Second;
     SetLocalTime(ref updatedTime);
 }
开发者ID:khaha2210,项目名称:CodeNewHis,代码行数:13,代码来源:frm_MainForm_new.cs


示例17: GetTimeFormatW

 static extern int GetTimeFormatW(uint locale, uint dwFlags, ref SystemTime time, string format, StringBuilder sb, int sbSize);
开发者ID:CheneyWu,项目名称:coreclr,代码行数:1,代码来源:GlobLocHelper.cs


示例18: GetDateFormat

 static extern int GetDateFormat(int locale, uint dwFlags, ref SystemTime sysTime, string format, StringBuilder sb, int sbSize);
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:1,代码来源:XsltFunctions.cs


示例19: SetLocalTime

 public extern static int SetLocalTime(ref SystemTime st);
开发者ID:ZoeCheck,项目名称:128_5.6_2010,代码行数:1,代码来源:ClientRB.cs


示例20: GetSystemTime

 static extern void GetSystemTime(SystemTime st);
开发者ID:haspeleo,项目名称:Algorithms-implementation,代码行数:1,代码来源:SuperDate3.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# T4MVC_ActionResult类代码示例发布时间:2022-05-24
下一篇:
C# SystemMediaTransportControls类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap