【发布时间】:2020-10-20 16:47:56
【问题描述】:
包含更改时间例程的程序在 Borland Delphi 7 IDE 中运行时确实会更改时间。但是当它独立运行时(在 Delphi IDE 之外),它不会改变时间。我正在使用 Windows 7。你能帮忙吗?谢谢。
...
procedure TForm1.changetime;
begin
DateSeparator:='-';
ShortDateFormat:='yyyy-MM-dd';
LongDateFormat:='yyyy''Year'',MM''Month'',dd''Date''';
TimeSeparator:=':';
DateTimetoString(date,'yyyy-mm-dd',now);
DateTimetoString(time,'hh:nn:ss',now);
cd:='2014-06-01 '+time;
d1:=StrToDateTime(cd);
DateTimeToSystemTime(d1,systemtime);
SetLocalTime(SystemTime);
end;
...
【问题讨论】:
-
这太复杂了——你可以马上做
systemtime.wYear:= 2014;。 -
您大概知道设置时间是一项管理员任务。你为什么要编写一个程序来做到这一点?