Created
July 7, 2017 12:34
-
-
Save atao/c0e45628081c837cab7a52adf01ce9d6 to your computer and use it in GitHub Desktop.
Change wallpaper
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# http://www.ghislain-lerda.com/2016/10/07/change-wallpaper/ | |
$wallpaperPath = "mon_image.png" | |
$setwallpapersource = @" | |
using System.Runtime.InteropServices; | |
public class wallpaper | |
{ | |
public const int SetDesktopWallpaper = 20; | |
public const int UpdateIniFile = 0x01; | |
public const int SendWinIniChange = 0x02; | |
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)] | |
private static extern int SystemParametersInfo (int uAction, int uParam, string lpvParam, int fuWinIni); | |
public static void SetWallpaper ( string path ) | |
{ | |
SystemParametersInfo( SetDesktopWallpaper, 0, path, UpdateIniFile | SendWinIniChange ); | |
} | |
} | |
"@ | |
Add-Type -TypeDefinition $setwallpapersource | |
[wallpaper]::SetWallpaper($wallpaperPath) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment