首页 > 其他 > 详细

【转】修改系统时间

时间:2018-12-08 15:09:37      阅读:148      评论:0      收藏:0      [点我收藏+]

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

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!