Example Code

Set Windows Desktop Background Image in 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

Overview

The Windows API is a very powerful tool that will let you, for the most part, completely customize your environment programmatically.

 

Description

This example uses the Windows API to programmatically set the the desktop wallpaper image.  This program uses the user32.dll and the SystemParameeresInfoA function to set the background image.

 

Requirements

  • LabVIEW 2013 (or compatible).

 

Steps to Implement or Execute Code

  1. Simply select a path to an image and run the code.
  2. The background with change to the image you selected.
 

Additional Information or References

VI Snippet

SetDesktopBackground.png

 

 

 

 

 

 
Call Library function configuration

CallLibraryConfig.PNG

 

 

**This document has been updated to meet the current required format for the NI Code Exchange.**

Cole R.
National Instruments
Software Engineer

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

Comments
B_Strange
Member
Member
on

Thanks for this! I was messing around with making tile patterns for my desktop and getting tired of resetting the desktop background manually over and over.

 

I have one note to add: I had to make sure that the image was saved as a bitmap before it would work. If the image is saved as, say a png, it will not change the background and also not throw an error. It might work for other image types but I didn't test them all.

JLohse
Member
Member
on

Thank you for this example, it really helped.

 

I have noticed that, at least on Win10, using the example code does change the background but it changes back on reboot.

Changing the bottom option to 1 instead of 0 keeps the background even on PC reboot. 

 

It might be a good idea to update the code example with this change.