-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
61 lines (48 loc) · 1.65 KB
/
Program.cs
File metadata and controls
61 lines (48 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
using System.Runtime.InteropServices;
namespace WallPaper
{
internal static class Program
{
[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_SENDWININICHANGE = 0x02;
public static string[] wallpaperPaths;
[STAThread]
static void Main()
{
ApplicationConfiguration.Initialize();
Application.Run(new FrmMain());
}
public static void GetWallPapers()
{
string str;
if (FrmMain.PNGfile != null)
{
str = FrmMain.PNGfile;
}
else
str = @"C:\Wallpapers";
wallpaperPaths = Directory.GetFiles(str + @"\", "*.png");
}
public static void ChangeWallpaper(int index)
{
string newWallpaper;
newWallpaper = wallpaperPaths[index];
SetDesktopBackground(newWallpaper);
}
private static void SetDesktopBackground(string wallpaperPath)
{
int result = SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, wallpaperPath, SPIF_UPDATEINIFILE | SPIF_SENDWININICHANGE);
if (result == 0)
{
Console.WriteLine("¸ü»»Ê§°Ü");
}
else
{
Console.WriteLine("¸ü»»³É¹¦");
}
}
}
}