zoukankan      html  css  js  c++  java
  • 修改系统时间(取得服务器时间,使用SetLocalTime API函数,需要UAC权限)

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

    第一步,把下面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

    https://www.cnblogs.com/kinglandsoft/p/10087576.html

  • 相关阅读:
    linux-log-files/
    SSL SSH
    C++学习的书籍
    Linux IO 分析
    LINUX 常用操作
    Find Large Files in Linux
    Linux 常见操作
    Linux Performance tool
    /linux-command-line-bash-shortcut-keys/
    Sed
  • 原文地址:https://www.cnblogs.com/findumars/p/10095553.html
Copyright © 2011-2022 走看看