Set-Wallpaper: Unterschied zwischen den Versionen
Aus Wiki-WebPerfect
Admin (Diskussion | Beiträge) (Die Seite wurde neu angelegt: „<source lang="powershell"> Function Set-WallPaper($Value) { Set-ItemProperty -path 'HKCU:\Control Panel\Desktop\' -name wallpaper -value $value rundll32.exe…“) |
Admin (Diskussion | Beiträge) |
||
Zeile 7: | Zeile 7: | ||
+ | == .NET == | ||
+ | <source lang="powershell"> | ||
+ | $SetWallpaperSrc = @' | ||
+ | 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 $SetWallpaperSrc | ||
+ | [wallpaper]::SetWallpaper($PathToSaveImagesAndSavedImageName) | ||
+ | </source> | ||
Aktuelle Version vom 6. Dezember 2018, 17:03 Uhr
Function Set-WallPaper($Value) { Set-ItemProperty -path 'HKCU:\Control Panel\Desktop\' -name wallpaper -value $value rundll32.exe user32.dll, UpdatePerUserSystemParameters }
.NET
$SetWallpaperSrc = @' 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 $SetWallpaperSrc [wallpaper]::SetWallpaper($PathToSaveImagesAndSavedImageName)