Skip to content

Class Desktop

Kristian Virtanen edited this page Oct 23, 2024 · 8 revisions

Description:

The Desktop class provides functionality to retrieve the dimensions of the primary screen (desktop) and change the desktop wallpaper. It uses the SystemParametersInfo function from the Windows API (user32.dll) to update the wallpaper.

It also manages error handling through the LastError property, which stores the most recent error message if an operation fails.

Properties

Desktop.Height

  • Description: Returns the height of the primary screen (desktop) in pixels.
  • Example: 1080

Desktop.LastError

  • Description: Stores the last error message, if any operation fails, including a timestamp in yyyy-MM-dd HH:mm:ss format.
  • Example: "2024-10-16 14:30:00: Failed to set wallpaper. Win32 Error Code: 87 - The parameter is incorrect."

Desktop.Width

  • Description: Returns the width of the primary screen (desktop) in pixels.
  • Example: 1920

Methods

Desktop.SetWallpaper(fileOrUrl)

  • Description: Sets the desktop wallpaper to the specified file path or URL.
  • Parameters:
    • fileOrUrl: The file path or URL of the image to set as wallpaper.
  • Returns: true if successful, false if an error occurred.
  • On Error: If the operation fails, LastError will contain the reason.

Top

Clone this wiki locally