Phenixa Posted September 22, 2005 Posted September 22, 2005 hi, i am working on a chat program i want my client to set wallpaper as i want how will i send a picture to it and set it as wallpaper? in c# Quote
Nate Bross Posted September 22, 2005 Posted September 22, 2005 Edit-Just realised you wanted to know how to send it and how to set it. See this thread for sending binary files. http://www.xtremedotnettalk.com/showthread.php?t=93025 This is how I do it in Visual Basic, it shouldn't be very dificult to convert. You may also need to delete this file after calling the function. C:\Documents and Settings\**CURRENTUSERNAME**\Local Settings\Application Data\Microsoft\Wallpaper1.bmp 'CONSTANTS Private Const SPI_SETDESKWALLPAPER As Integer = &H14 Private Const SPIF_UPDATEINIFILE As Integer = &H1 Private Const SPIF_SENDWININICHANGE As Integer = &H2 'API Declares 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 Friend Sub SetWallpaper(ByVal img As Image, ByVal PathToImage As String) Dim imageLocation As String Dim FileName As String imageLocation = PathToImage Dim tmp = Split(imageLocation, "\") FileName = tmp(UBound(tmp)) Try img.Save(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures) & FileName, System.Drawing.Imaging.ImageFormat.Bmp) SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, imageLocation, _ SPIF_UPDATEINIFILE Or SPIF_SENDWININICHANGE) Catch Ex As Exception MsgBox("There was an error setting the wallpaper: " & Ex.Message) End Try End Sub Quote ~Nate� ___________________________________________ Please use the [vb]/[cs] tags on posted code. Please post solutions you find somewhere else. Follow me on Twitter here.
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.