Solved

TIME_ZONE_INFORMATION or TTimeZoneInformation

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

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…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

920 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

15 Experts available now in Live!

Get 1:1 Help Now