[나크21] 캐주얼 미니스커트 치마바지 NK21-P-10
BLOG main image
분류 전체보기 (540)
▩▩ 개인공간 ▩▩ (124)
▩▩ 문화생활 ▩▩ (45)
▩▩ 게임 ▩▩ (211)
▩▩ 일러스트 ▩▩ (46)
▩▩ 프로그래밍 ▩▩ (73)
▩▩ 코스메틱 ▩▩ (1)
▩▩ 여행 ▩▩ (0)
* 셈틀 롤드컵 * (1)
반응형
Total
Today hit
Yesterday hit
▩▩ 프로그래밍 ▩▩/C#
반응형

리소스에 추가되있는 이미지 파일로 바탕화면 바꾸기


// 추가
using System.Runtime.InteropServices;
using System.IO;


const int SPI_SETDESKWALLPAPER = 20;
const int SPIF_UPDATEINIFILE = 0x01;
const int SPIF_SENDWININICHANGE = 0x02;

[DllImport("user32.dll", CharSet = CharSet.Auto)]
static extern int SystemParametersInfo(int uAction, int uParam, string lpvParam, int fuWinIni);


public enum Style : int
{
                        Tiled,
                        Centered,
                        Stretched
}


public static void Set(string wpaper, Style style)
{
                        System.Drawing.Image img = Properties.Resources.login;
                        string tempPath = Path.Combine(Path.GetTempPath(), "wallpaper.bmp");
                        img.Save(tempPath, System.Drawing.Imaging.ImageFormat.Bmp);

                        Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(@"Control Panel\Desktop", true);
                        if (style == Style.Stretched)
                        {
                                key.SetValue(@"WallpaperStyle", 2.ToString());
                                key.SetValue(@"TileWallpaper", 0.ToString());
                        }
                        if (style == Style.Centered)
                        {
                                key.SetValue(@"WallpaperStyle", 1.ToString());
                                key.SetValue(@"TileWallpaper", 0.ToString());
                        }
                        if (style == Style.Tiled)
                        {
                                key.SetValue(@"WallpaperStyle", 1.ToString());
                                key.SetValue(@"TileWallpaper", 1.ToString());
                        }
                        SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, tempPath,  SPIF_UPDATEINIFILE | SPIF_SENDWININICHANGE);
}


반응형