• 【转】修改系统时间


    我的客户遇到系统时间不对,自己又不会改,于是想到利用服务端时间来修改本地的系统时间。

    第一步,把下面xml存成uac.xml文件备用。

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>  
    <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">  
    <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">  
    <security>  
    <requestedPrivileges>  
    <requestedExecutionLevel level="requireAdministrator" uiAccess="false">  
    </requestedExecutionLevel>  
    </requestedPrivileges>  
    </security>  
    </trustInfo>  
    <dependency>  
    <dependentAssembly>  
    <assemblyIdentity type="win32"  
    name="Microsoft.Windows.Common-Controls"  
    version="6.0.0.0"  
    processorArchitecture="x86"  
    publicKeyToken="6595b64144ccf1df"  
    language="*">  
    </assemblyIdentity>  
    </dependentAssembly>  
    </dependency>  
    </assembly> 

    接下来,看代码:

    procedure TForm12.SyncLocalDateTime;//同步本地时间
    var
      systemtime: Tsystemtime;
      DateTime: TDateTime;
    begin
      SetLocaleInfo(LOCALE_SYSTEM_DEFAULT, LOCALE_SSHORTDATE, 'yyyy-MM-dd');
      DateTime := GetServerDateTime;//取服务器日期
      System.Sysutils.DateTimeToSystemTime(DateTime, systemtime);
      SetLocalTime(systemtime);
    end;

    需要引用单元:Winapi.Windows

    编译时,使用刚才做的uac.xml文件:

    在Delphi 10.3+win10测试通过。

    原文地址:https://www.cnblogs.com/stroll/p/6913769.html

  • 相关阅读:
    浅谈 C++ 多态性
    浅谈 C++ 继承
    C++ 深拷贝浅拷贝
    C++ 斐波那契数列
    C++ 指针函数和lambda
    设计模式之单例模式
    结构体中内存对齐和补齐
    AWS S3文件存储工具类
    Java Springboot学习(三) Thymeleaf 、mybatis-plus
    Java Springboot学习(三) 整合springmvc、jdbc、mybatis
  • 原文地址:https://www.cnblogs.com/kinglandsoft/p/10087576.html
Copyright © 2020-2023  润新知