Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

GetTimeZoneInformation function

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Can someone show me how to use the GetTimeZoneInformation function???
 
Try this or something similar:
Code:
TZId = GetTimeZoneInformation((LPTIME_ZONE_INFORMATION) &TimeZoneInformation );

switch (TZId)
{
    case TIME_ZONE_ID_UNKNOWN:
         // Do something
         break;

     case TIME_ZONE_ID_STANDARD:
           // Do something
           break;

      case TIME_ZONE_ID_DAYLIGHT:
            // Do something
            break;

       default:
           //
           // Something is wrong with the time zone information.  Fail
           // the logon request.
           //

           NtStatus = STATUS_INVALID_LOGON_HOURS;
           break;
}

if (NT_SUCCESS(NtStatus))
{
    // Do something 
}


James P. Cottingham

I am the Unknown lead by the Unknowing.
I have done so much with so little
for so long that I am now qualified
to do anything with nothing.
 
Thanks James for the code,

The complier didn't like the: TZId = GetTimeZoneInformation((LPTIME_ZONE_INFORMATION) &TimeZoneInformation );

Error being: Undefined symbol 'TimeZoneInformation'. and the Switch(TZId)line gave the error: Switch selection expression must be of integral type..

I didn't use any of the NtStatus lines as these were causing problems.

Your code with the Switch() is exactly what I want so I can run a program depending if it is daylight savings or not.

Can you see why the lines, TZId = GetTimeZoneInformation((LPTIME_ZONE_INFORMATION) &TimeZoneInformation ); and the Switch(TZId) would not work??
 
My mistake, I forgot to define the variables. According to the sample code I have, you will need to define the following varaibles:
Code:
TIME_ZONE_INFORMATION TimeZoneInformation;
NTSTATUS NTStatus=STATUS_SUCCESS;
DWORD TZId;

TimeZoneInformation points to the structure of TIME_ZONE_INFORMATION. NTStatus has a type of NTSTATUS with an initial value of STATUS_SUCCESS. TZId is a double word. Hope this helps.
James P. Cottingham

I am the Unknown lead by the Unknowing.
I have done so much with so little
for so long that I am now qualified
to do anything with nothing.
 
The only prob now is the NTSTATUS NTStatus=STATUS_SUCCESS;

I use BCB3 Standard... is NTSTATUS a declaration/function for a higher version of BCB?
 
NTSTATUS should be part of MFC. It's not part of BCB. You can probably find another way to code this if you are desperate.
James P. Cottingham

I am the Unknown lead by the Unknowing.
I have done so much with so little
for so long that I am now qualified
to do anything with nothing.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top