06-12-2007 04:30 PM
I am trying to write a VI that will set the system time zone (in Windows). The user needs to be given the option to pick which time zone they are in. Then whatever changes are needed, must be written back out to Windows.
I want Windows to handle all the offsets and setting the local time. I just want to provide a way that the user can view a list of all the different time zones and pick one to set the local time by.
I have tried a couple different ways:
1. Calling the GetTimeZoneInformation in the kernel32.dll through the Call Library Function vi. However, I am not sure what input to give the node. I found documentation on:
http://msdn2.microsoft.com/en-us/library/ms724944.aspx
The issue arises when I attempt to create a cluster to match a TIME_ZONE_INFORMATION structure:
http://msdn2.microsoft.com/en-us/library/ms725481.aspx
I am having a very hard time figured out what data type WCHAR would be in my LabVIEW cluster.
2. Modifying the registry values at:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\TimeZoneInformation
The problem arises that even if I set the StandardName and DaylightName, the time zone settings have not changed when I go to check them in the system clock and the local time has not been altered to reflect any time zone change. All the possible time zones are located at: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones
I have been able to determine that the data in the TZI subkey is structured as:
long Bias;
long StandardBias;
long DaylightBias;
SYSTEMTIME StandardDate;
SYSTEMTIME DaylightDate;
SYSTEMTIME is another structure that is made up of eight words:
http://msdn2.microsoft.com/en-us/library/ms724950.aspx
The information contained in the TZI tag can entered into the subkeys in HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\TimeZoneInformation but I cannot figure out how to get the information in hex from that TZI tag into LabVIEW, divide it up and feed it back out.
If there is some other (hopefull easier) way to do this or if you can help me with either of the two ways I have already tried, I would greatly appreciate it. Please note that I cannot use any other tools that are not built-in to windows. So G-tools is out of the question.
Kyle
06-12-2007 04:54 PM
06-13-2007 01:46 AM
That is a very good point.
The user needs to be given the option to pick which time zone they are in.
They already have that option. You double click the clock at the bottom of the screen and go into the Time Zone tab.
Why try to work around that just for the sake of your application?
I understand the need to try to make things easier for the users, but there is some point at which you should say no.
As for the actual question, I believe that WChar is a Unicode string (2 bytes for each character), so you need to allocation 2n bytes (an array of U8) and have the first byte of each pair be 0. There is a VI called by the registery VIs which does this conversion for you (it's called STR_ASCII-Unicode.vi).
In any case, if you must do this from your application, I suggest you simply call the date/time dialog.
One way would be to run the System Exec VI with "rundll32.exe shell32.dll,Control_RunDLL timedate.cpl" as the input, but there are probably other ways.
06-13-2007 08:00 AM
06-13-2007 12:13 PM
Setting the time zone is a system-wide operation which ideally should be performed only once.
Would it really be that critical to have it as part of your application?
Why not just boot up once into the Windows shell and set everything that needs setting as part of the installation process?
06-13-2007 01:25 PM
06-13-2007 11:37 PM
06-14-2007 04:46 AM
@TonP wrote:
I believe the timezone is only read during initalization of LabVIEW
Good point. I forgot about that one.
I haven't checked it recently, but I assume that still happens in the newer versions.
06-14-2007 07:34 AM