Solved

How can I change system Date/time !!

Posted on 1998-10-08
4
144 Views
Last Modified: 2010-04-06
It is very easy question.
What is the Delphi procedures which set date and time ?

Motaz
0
Comment
Question by:Motaz
  • 3
4 Comments
 
LVL 5

Accepted Solution

by:
scrapdog earned 0 total points
Comment Utility
You axed it twice, I'll answer it twice!!


Here is the data structure:

TSystemTime = record
    wYear: Word;
    wMonth: Word;
    wDayOfWeek: Word;
    wDay: Word;
    wHour: Word;
    wMinute: Word;
    wSecond: Word;
    wMilliseconds: Word;
  end;


Set the date time like this:

var
  NewTime :TSystemTime;

NewTime.wYear := 1998;   ,etc, etc.

Then you call the function SetSystemTime

SetSystemTime(NewTime);


If you only wanted to change one part of the system time, you could call GetSystemTime

GetSystemTime(NewTime);
NewTime.wYear := 1999;
SetSystemTime(NewTime);


The SetSystemTime function returns a boolean, indicating whether it succeeded or not.  

OK := SetSystemTime(NewTime);
if not OK then ShowMessage('Time not set');




Make sure that Windows is in your uses clause if you use any of these functions.
0
 
LVL 7

Author Comment

by:Motaz
Comment Utility
Thanks Scrap, But I don't ask this question befor ??  :)

Motaz
0
 
LVL 7

Author Comment

by:Motaz
Comment Utility
Thanks Scrap, But I don't ask this question befor ??  :)

Motaz
0
 
LVL 7

Author Comment

by:Motaz
Comment Utility
Oh !!. How did you do that ? ( Answering twice ???? )
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
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…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

762 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

9 Experts available now in Live!

Get 1:1 Help Now