There are no built in LabVIEW VIs to set the system time. However, this can be accomplished using the Windows SDK. Here are the instructions to use a Call Library Function Node to call the SetSystemTime
function from the kernel32.dll:
- Place a Call Library Function Node on the block diagram. Double-click the node to open the Call Library Function dialog box.
- Click the Browse button and select the kernel32.dll (usually found at C:\WINDOWS\system32\kernel32.dll").
- Select SetSystemTime from the Function Name drop-down list.
- Select stdcall (WINAPI) from the Calling Conventions drop-down list.
- For Return Type select "Numeric" and select "Signed 8-bit Integer".
- Click Add a Parameter After and for Type select "Adapt to Type" and for Data Format select "Pointers to Handles".
- Click the OK button to configure the Call Library Function Node.
- This function takes a structure of eight WORDS (16-bit integers) as a parameter. To replicate this in LabVIEW, create a cluster of eight WORDS. The eight WORDS represent the Year, Month, Day of Week, Day of Month, Hour, Minute, Second, and Millisecond. Wire the cluster to the param 1 input of the Call Library Function Node.
- Enter the desired values and run the program to set the system time.
If you are calling the SetSystemTime from LabVIEW in Windows Vista or later, you must run LabVIEW as an administrator. To do this, right-click the LabVIEW icon and select Run as administrator
Refer to the SetSystemTime documentation on msdn.com
for more information on this function. Note that a GetSystemTime function also exists in kernel32.dll.
For more information about configuring the Call Library Function Node in LabVIEW 7.1 or earlier, refer to the Using External Code in LabVIEW
manual. In LabVIEW 8.0 or later, refer to the Configuring the Call Library Function Node topic in the LabVIEW Help
for more information.