Solved

Change Windows Date from Delphi

Posted on 2000-04-12
6
298 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
Comment Utility
Hi

use the SetSystemTime function.

regards
rene

0
 

Author Comment

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

Expert Comment

by:rene100
Comment Utility
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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 

Author Comment

by:rainbowsoftware
Comment Utility
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
Comment Utility
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
Comment Utility
thanks a lot, just what I needed.
Joern
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

772 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now