synctimeCS/Form1.cs

(开头部分) 4KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.Runtime.InteropServices;
using System.Text;
using System.Text.RegularExpressions;
using System.Windows.Forms;
using System.IO;

namespace synctimeCS
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            this.label5.Text = "";

            this.timer1.Interval = 1000;
            this.timer1.Start();
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            SYSTEMTIME st = new SYSTEMTIME();
            //获取北京时间
            {
                WebRequest wrt = WebRequest.Create("http://open.baidu.com/special/time/");
                wrt.Credentials = CredentialCache.DefaultCredentials;
                WebResponse wrp = wrt.GetResponse();
                StreamReader sr = new StreamReader(wrp.GetResponseStream(), Encoding.UTF8);
                string html = sr.ReadToEnd();
                string timeStamp = html.Substring(html.IndexOf("window.baidu_time(") + 18, 13);
                DateTime dateTimeStart = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1));
                long lTime = long.Parse(timeStamp + "0000");
                TimeSpan toNow = new TimeSpan(lTime);
                DateTime dt = dateTimeStart.Add(toNow);

                this.label2.Text = dt.ToString("yyyy/MM/dd HH:mm:ss");
            }

            //获取本地时间
            {
                GetLocalTime(ref st);
                this.label4.Text = st.ToDateTime().ToString("yyyy/MM/dd HH:mm:ss");
            }
        }

        #region Kernel32.dll相关函数
        [StructLayout(LayoutKind.Sequential)]
后面还有 59 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。