<?xml version="1.0"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
  <CodeSnippet Format="1.0.0">
    <Header>
      <Title>Set the Windows desktop wallpaper</Title>
      <Author>paulyuk</Author>
      <Description>Set the Windows desktop wallpaper using PInvoke</Description>
      <Shortcut>setwallpaper</Shortcut>
    </Header>
    <Snippet>
      <Declarations>
        <Literal>
          <ID>imagePath</ID>
          <Type>String</Type>
          <ToolTip>Set the path where the image will be saved</ToolTip>
          <Default>"MovieCollectionImage.bmp"</Default>
        </Literal>
      </Declarations>
      <Code Language="VB" Kind="method decl"><![CDATA[Private Const SPI_SETDESKWALLPAPER As Integer = &H14
Private Const SPIF_UPDATEINIFILE As Integer = &H1
Private Const SPIF_SENDWININICHANGE As Integer = &H2
Private Declare Auto Function SystemParametersInfo Lib "user32.dll" (ByVal uAction As Integer, ByVal uParam As Integer, ByVal lpvParam As String, ByVal fuWinIni As Integer) As Integer
Const WallpaperFile As String = $imagePath$

Friend Sub SetWallpaper(ByVal img As Image)
	Dim imageLocation As String
	imageLocation = My.Computer.FileSystem.CombinePath(My.Computer.FileSystem.SpecialDirectories.MyPictures, WallpaperFile)
	img.Save(imageLocation, System.Drawing.Imaging.ImageFormat.Bmp)
	SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, imageLocation, SPIF_UPDATEINIFILE Or SPIF_SENDWININICHANGE)
End Sub
]]></Code>
    </Snippet>
  </CodeSnippet>
</CodeSnippets>