BITKit/Src/Unity/Scripts/Win64/GetWindowsWallPaper.cs

29 lines
759 B
C#

using System.Collections;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text;
using UnityEngine;
namespace BITKit
{
public class GetWindowsWallPaper
{
[DllImport("user32.dll", SetLastError = true)]
static extern bool SystemParametersInfo(int uAction, int uParam, StringBuilder lpvParam, int fuWinIni);
const int SPI_GETDESKWALLPAPER = 0x0073;
const int MAX_PATH = 260;
public static string GetWallpaperPath()
{
StringBuilder sb = new StringBuilder(MAX_PATH);
if (SystemParametersInfo(SPI_GETDESKWALLPAPER, sb.Capacity, sb, 0))
{
return sb.ToString();
}
return null;
}
}
}