Solved

TIME_ZONE_INFORMATION or TTimeZoneInformation

Posted on 2000-05-09
5
1,803 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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 video discusses moving either the default database or any database to a new volume.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

706 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

19 Experts available now in Live!

Get 1:1 Help Now