Example Code

Programmatically change your Windows Wallpaper

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

1. Overview:
This VI programmatically changes windows wallpaper


2. Description: 

The example calls the SystemParametersInfoA function from Windows user32 API:

BOOL WINAPI SystemParametersInfo(
  __in     UINT uiAction,
  __in     UINT uiParam,
  __inout  PVOID pvParam,
  __in     UINT fWinIni
);

 

- SPI_SETDESKWALLPAPER Sets the desktop wallpaper
- The value of the pvParam parameter determines the new wallpaper. To specify a wallpaper bitmap, set pvParam to point to a NULL-terminated string containing the full path to the bitmap file. Setting pvParam to "" removes the wallpaper. Setting pvParam to SETWALLPAPER_DEFAULT or NULL everts to the default wallpaper.

- For more information, reference MSDN documentation for this function here SystemParametersInfo Function.

 

3. Requirements

  • LabVIEW 2012 (or compatible)

4. Steps to Implement or Execute Code

  1. Select the path to the wallpaper image (must be .jpg)
  2. Run the VI
  3. Selected wallpaper will be set

5. Additional Information or References

 VI Block Diagram

 

Snippet.png

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

--Michelle

National Instruments

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