Solved

Change Windows Date from Delphi

Posted on 2000-04-12
6
302 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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Sending Gmail through Delphi 3 108
LAN or WAN ? 11 92
When i run adoquery my application freezes 26 166
Firemonkey android show image from resource ? 1 42
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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

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