Example Code

Programmatically lock Microsoft Windows PC/Workstation using LabVIEW

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • LabVIEW

Code and Documents

Attachment

Description

1. Overview

This VI shows how to lock a windows workstation programmatically

 

2. Description

This example VI calls the function LockWorkstation from the Microsoft Windows' dynamic link library (DLL) User32 whenever a boolean control is activated.

 

3. Requirements

  • NI LabVIEW Base Development System 2012 or compatible.

 

4. Steps to Implement or Execute Code

  1. Download, open, and run the VI.
  2. Click the "Lock PC" button to trigger the event structure that executes the Call Library Function Node, to lock your PC.
  3. Unlock your PC (you will need to enter your password if you have configured one).
  4. Click the Stop button when you are done testing the VI.

 

5. Additional Information or References

 

Lock PC programmatically Screenshot.PNG

 

**The code for this example has been edited to meet the new Community Example Style Guidelines.**

Ashish Naik
Automotive Business Development Manager
National Instruments UK

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
david.bolt
NI Employee (retired)
on

This is fantastic. I will now use this and save 0.1seconds instead of locking my screen via my keyboard everyday! Thats more than half a minute a year!!! Thanks!

Many thanks for using the NI forums and I look forward to your reply.

Kind regards

David

Applications Engineer
National Instruments UK