Solved

Change Windows Date from Delphi

Posted on 2000-04-12
6
312 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
Industry Leaders: 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

Get HTML5 Certified

Want to be a web developer? You'll need to know HTML. Prepare for HTML5 certification by enrolling in July's Course of the Month! It's free for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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 this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Suggested Courses
Course of the Month10 days, 17 hours left to enroll

628 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