网上流行的SetLocaleInfo方法有时不起作用,直接写注册表最有效
代码如下:
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
![ExpandedBlockStart.gif](https://images.cnblogs.com/OutliningIndicators/ExpandedBlockStart.gif)
procedure
SetWindowDate(sshortdate:
string
=
'
yyyy-MM-dd
'
;sTimeFormat:
string
=
'
HH:mm:ss
'
;sTime:
string
=
'
:
'
;sDate:
string
=
'
-
'
);
//
设置日期格式为 yyyy
-
mm
-
dd
var
registerTemp: TRegistry;
begin
registerTemp : = TRegistry.Create; // 准备使用注册表
with registerTemp do
begin
RootKey : = HKEY_Current_user; // 存放在此根下
if OpenKey( ' control panel\international ' , True) then
begin
Writestring( ' sshortdate ' , sshortdate);
Writestring( ' sTimeFormat ' , sTimeFormat);
Writestring( ' sTime ' ,sTime);
Writestring( ' sDate ' , sDate);
end ;
end ;
registertemp.Free;
end ;
var
registerTemp: TRegistry;
begin
registerTemp : = TRegistry.Create; // 准备使用注册表
with registerTemp do
begin
RootKey : = HKEY_Current_user; // 存放在此根下
if OpenKey( ' control panel\international ' , True) then
begin
Writestring( ' sshortdate ' , sshortdate);
Writestring( ' sTimeFormat ' , sTimeFormat);
Writestring( ' sTime ' ,sTime);
Writestring( ' sDate ' , sDate);
end ;
end ;
registertemp.Free;
end ;