Solved

Change Windows Date from Delphi

Posted on 2000-04-12
6
305 Views
Last Modified: 2011-09-20
How can I change Windows system date from a Delphi application?
Joern
0
Comment
Question by:rainbowsoftware
  • 3
  • 3
6 Comments
 
LVL 2

Accepted Solution

by:
rene100 earned 100 total points
ID: 2708680
Hi

use the SetSystemTime function.

regards
rene

0
 

Author Comment

by:rainbowsoftware
ID: 2709364
I'm rather confused, could you please give me a hint?
Joern
0
 
LVL 2

Expert Comment

by:rene100
ID: 2709456
I'm sorry, the SetLocalTime funtion is bettter, because you don't have to care about time zones etc.
example:

procedure TForm1.Button1Click(Sender: TObject);
var
sys: tsystemtime;
begin
sys.wSecond:=1;
sys.wDay:=1;
sys.wHour:=7;
sys.wDayOfWeek:=3; //ignored
sys.wMilliseconds:=5;
sys.wMinute:=30;
sys.wMonth:=5;
sys.wYear:=2001;
if SetLocalTime(sys)=true then
   showmessage('Time changed!');
end;

this sets the system-time to 1.5.2001 7:30:01

regards
rene
0
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:rainbowsoftware
ID: 2712492
Thanks to Rene for a perfect solution.
Maybe you could tell me, if there is a simple way to change the system date format from dd-MM-yy to dd-MM-yyyy from within a Delphi application.
Joern
0
 
LVL 2

Expert Comment

by:rene100
ID: 2712962
This should work:

if SetLocaleInfo(LOCALE_system_DEFAULT,LOCALE_SLONGDATE,pchar('dd.MM.yyyy ')) then
   showmessage('Dateformat changed!');
Ig you want to change teh shortdate-format, use LOCALE_SSHORTDATE instead of _SLONGDATE.
Be aware that the new date is case sensitive: 'DD.mm.YYYY' will not work.

regards
rene
0
 

Author Comment

by:rainbowsoftware
ID: 2719015
thanks a lot, just what I needed.
Joern
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question