Skip to content

Class Clock

Kristian Virtanen edited this page Oct 16, 2024 · 11 revisions

Description:

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

It also provides error handling through the LastError property, which captures the most recent error message, if any operation fails.

Properties

Desktop.Width

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

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."

Methods

Desktop.SetWallpaper(fileOrUlr)

  • 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