Solved

Change Windows Date from Delphi

Posted on 2000-04-12
6
310 Views
Last Modified: 2011-09-20
How can I change Windows system date from a Delphi application?
Joern
0
Comment
Question by:rainbowsoftware
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Suggested Solutions

Title # Comments Views Activity
Magic Software info 18 156
tvirtualstringtree freeze when load too manny images 10 94
delphi popmenu non latine charcters 3 49
TlistView is Really heavy on Android 3 44
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…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

752 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