Solved

TIME_ZONE_INFORMATION or TTimeZoneInformation

Posted on 2000-05-09
5
1,869 Views
Last Modified: 2012-05-04
I want to use the GetTimeZoneInformation WinAPI function, but it needs the structure TIME_ZONE_INFORMATION passed to it.

Examples of the usage of this function use the TTimeZoneInformation structure, but my version (D2) does not seem to know it.

Could someone please provide the definition of this structure?
0
Comment
Question by:sderaadt
  • 2
  • 2
5 Comments
 
LVL 7

Expert Comment

by:Motaz
ID: 2795508
Did you test such code:

procedure TForm1.FormCreate(Sender: TObject);
var
  Zone: TIME_ZONE_INFORMATION;
begin
  GetTimeZoneInformation(Zone);
end;

Motaz
0
 
LVL 20

Accepted Solution

by:
Madshi earned 50 total points
ID: 2795630
First you should look into your windows.pas unit. Look at the definition of GetTimeZoneInformation. What type did Borland use there? You should use that type, too.

Well, anyway, here is the structure:

type
 TIME_ZONE_INFORMATION = record
    Bias: Longint;
    StandardName: array[0..31] of WCHAR;
    StandardDate: TSystemTime;
    StandardBias: Longint;
    DaylightName: array[0..31] of WCHAR;
    DaylightDate: TSystemTime;
    DaylightBias: Longint;
  end;

Regards, Madshi.
0
 

Author Comment

by:sderaadt
ID: 2798092
Madshi

Thanks for the definition. I tried it, but still the same error:

'Types of actual and formal var parameters must be identical'

This is the code I have:
>>>>>
Type
     TIME_ZONE_INFORMATION = record
          Bias: Longint;
          StandardName: array[0..31] of WCHAR;
          StandardDate: TSystemTime;
          StandardBias: Longint;
          DaylightName: array[0..31] of WCHAR;
          DaylightDate: TSystemTime;
          DaylightBias: Longint;
     end;

procedure TfEdit.Button1Click(Sender: TObject);
var
     tzi : TTimeZoneInformation;
     iRes : integer;
begin
     iRes := GetTimeZoneInformation(tzi);
end;

>>>>>

Although TIME_ZONE_INFORMATION (or TTimeZoneInformation) was not defined in my windows.pas, TSystemTime is.

Whats wrong? Is TSystemTime defined in my windows.pas wrong?

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

I am using Delphi Desktop 2.0.

Cheers

sderaadt

0
 
LVL 20

Expert Comment

by:Madshi
ID: 2799017
>> 'Types of actual and formal var parameters must be identical'

This error tells you that Delphi wants to have a different type in the GetTimeZoneInformation call.
Please look in "Windows.pas" (or if you don't find it there, in all other units) for the definition "GetTimeZoneInformation". What type is used as the parameter there? I don't have D2 installed anymore, so I can't look myself...

Regards, Madshi.
0
 

Author Comment

by:sderaadt
ID: 2802363
Madshi

Thanks for the help - it appears there was a small typo somewhere in my code, but its working now.
0

Featured Post

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

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…
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…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

820 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