Darth_helge
asked on
getting/setting the short dateformat in windows by using delphi?
how do i do this?
Our application must have a specific short dateformat.
You can find the dateformat i want to change by clicking control panel-->regional settings-->short dateformat
Our application must have a specific short dateformat.
You can find the dateformat i want to change by clicking control panel-->regional settings-->short dateformat
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You don't have to change anything in Windows.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
oops Dtscheiding should be DtSepar
Darth_helge, if you get the Date from windows :
var
CurrDate : String;
begin
CurrDate := MyDateToStr(Now);
the implementation of MyDateToStr - see my post above. I think you should not change anything in Windows.
just another way
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Edit1: TEdit;
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
//get
procedure TForm1.Button1Click(Sender : TObject);
var
P : array[0..100] of char;
begin
getLocaleInfo(LOCALE_USER_ DEFAULT,LO CALE_SSHOR TDATE,p,Si zeOf(p));
ShowMessage(p);
end;
//set
procedure TForm1.Button2Click(Sender : TObject);
var s : String;
begin
s := edit1.Text;
setLocaleInfo(LOCALE_USER_ DEFAULT,LO CALE_SSHOR TDATE,PCha r(s));
end;
end.
meikl ;-)
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Edit1: TEdit;
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
//get
procedure TForm1.Button1Click(Sender
var
P : array[0..100] of char;
begin
getLocaleInfo(LOCALE_USER_
ShowMessage(p);
end;
//set
procedure TForm1.Button2Click(Sender
var s : String;
begin
s := edit1.Text;
setLocaleInfo(LOCALE_USER_
end;
end.
meikl ;-)
Moreover You don't need set ShortDateFormat.
This variable is set when Your application starts and if variable UpdateFormatSettings is set to True (default setting) it is updated every time user changes Windows setting.
You need to set ShortDateFormat if You store/load dates in a string format and want to convert from string to date and vice versa.
This variable is set when Your application starts and if variable UpdateFormatSettings is set to True (default setting) it is updated every time user changes Windows setting.
You need to set ShortDateFormat if You store/load dates in a string format and want to convert from string to date and vice versa.
ASKER
sorry.. i was going to give more people points.. but i did wrong
ASKER
yes, there were many good answers here
ASKER
I don't have to change anything in Windows?