|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
x
 | |  |  | 本帖最后由 min00yuan 于 2017-12-11 13:35 编辑
发个小工具,修改系统时间格式的小工具,把系统时间格式修改为yyyy-MM-dd,或许会帮助到一些人,下面会贴出此文件在线扫描结果,实在不放心的朋友,源码我也会贴出,可自行编译,下载地址回复可见 ,解压密码就是 www.wooolc.com, - unit Unit1;
- interface
- uses
- Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
- Vcl.Controls, Vcl.Forms, Vcl.Dialogs,Winapi.msxml, System.DateUtils,
- Vcl.StdCtrls;
- type
- TForm1 = class(TForm)
- Button1: TButton;
- Label1: TLabel;
- Label2: TLabel;
- procedure Button1Click(Sender: TObject);
- procedure FormCreate(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
- var
- Form1: TForm1;
- implementation
- {$R *.dfm}
- function GetNetTime(aUrl: WideString = 'http://www.sohu.com'): string;
- begin
- with CoXMLHTTP.Create do
- begin
- open('Post', aUrl, False, EmptyParam, EmptyParam);
- send(EmptyParam);
- Result := getResponseHeader('Date');
- end;
- end;
- function GMT2BjDateTime(const GMT: string): TDateTime;
- var
- A: TArray;
- Y,M,D,H,N,S: Word;
- begin
- A := GMT.Split([',', ' ', ':'], ExcludeEmpty);
- with TStringList.Create do begin
- CommaText := 'Jan=1,Feb=2,Mar=3,Apr=4,May=5,Jun=6,Jul=7,Aug=8,Sep=9,Oct=10,Nov=11,Dec=12';
- A[2] := Values[A[2]];
- Free;
- end;
- Y := StrToIntDef(A[3], YearOf(Now));
- M := StrToIntDef(A[2], MonthOf(Now));
- D := StrToIntDef(A[1], DayOf(Now));
- H := StrToIntDef(A[4], HourOf(Now));
- N := StrToIntDef(A[5], MinuteOf(Now));
- S := StrToIntDef(A[6], SecondOf(Now));
- Result := EncodeDateTime(Y, M , D, H, N, S, 0);
- Result := Result + 8/24;
- end;
- procedure TForm1.Button1Click(Sender: TObject);
- var
- p:DWORD;
- systemtime:Tsystemtime;
- DateTime:TDateTime;
- begin
- SetLocaleInfo(LOCALE_USER_DEFAULT,LOCALE_SSHORTDATE,pchar('yyyy-MM-dd')); //短日期
- SetLocaleInfo(LOCALE_USER_DEFAULT,LOCALE_SLONGDATE,pchar('yyyy''年''M''月 ''d''日'''));
- SetLocaleInfo(LOCALE_USER_DEFAULT,LOCALE_STIMEFORMAT,pchar('H:mm:ss')); //设置时间
- SendMessageTimeOut(HWND_BROADCAST,WM_SETTINGCHANGE,0,0,SMTO_ABORTIFHUNG,10,p);
- GetLocalTime(SystemTime);
- DateTime:=SystemTimeToDateTime(SystemTime);
- label2.Caption:=' 本地系统时间为:'+ DateTimeToStr(DateTime);
- end;
- procedure TForm1.FormCreate(Sender: TObject);
- var
- strGMT: string;
- bjDateTime: TDateTime;
- systemtime:Tsystemtime;
- DateTime:TDateTime;
- begin
- strGMT := GetNetTime();
- bjDateTime := GMT2BjDateTime(strGMT);
- label1.Caption:= '搜狐服务器返回格林尼治时间转化为的北京时间:'+ datetimetostr(bjDateTime);
- GetLocalTime(SystemTime);
- DateTime:=SystemTimeToDateTime(SystemTime); //把API的TSystemTime格式 转化为 Delphi的TDateTime格式
- label2.Caption:=' 本地系统时间为:'+ DateTimeToStr(DateTime);
- end;
- end.
复制代码
| |  | |  |
|
评分
-
查看全部评分
|