i need to send a bitmap to my client and set it as wallpaper how can i do it in c#??

Phenixa

New member
Joined
Sep 22, 2005
Messages
1
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#
 
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.computerhelp.forum/showthread.php?t=93025

This is how I do it in Visual Basic, it shouldnt 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


Code:
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
 

Similar threads

D
Replies
0
Views
62
duoshock
D
J
Replies
0
Views
59
Jalil Sear [MCPD SharePoint]
J
M
Replies
0
Views
364
MohammadAlsheukh
M
Back
Top