delphi动态设置时间格式最有效方法

网上流行的SetLocaleInfo方法有时不起作用,直接写注册表最有效

代码如下:

代码
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;

 

posted @ 2010-01-07 15:19  高山峻岭  阅读(419)  评论(0)    收藏  举报