SystemParametersInfo will nicht

sharK223

Mitglied
Guten Tag Comunity,

ich sitzte derzeit an einem kleinen Problem in C#.
Ich wollte eigentlich nur ein kleines Programm schreiben welches
beim aufrufen ledeglich das Hintergrundbild ändert.
Leider komme ich nicht wirklich mit der WinAPI klar welche ich
zum erstemal benutzte.
Ich bekomme von Visual C# keinen Fehler zurück aber dennoch ändert
sich das Hintergrund Wallpaper nicht.

Hier der Code:
Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Collections;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.IO;

namespace WindowsFormsApplication1
{


    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {

            Bitmap bm = new Bitmap(Properties.Resources.wallpaper_1920x1080);
            bm.Save(Application.StartupPath + "\\wallpaper.bmp");
            int ergebnis = WinAPI.SystemParametersInfo(20, 0, Application.StartupPath + "\\wallpaper.bmp", 0x02);
        }

        private void linkLabel2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            Application.Exit();
        }      
    }
    
    public class WinAPI
    {
        [DllImport("user32.dll", CharSet=CharSet.Auto)]
        public static extern int SystemParametersInfo (int uAction , int uParam , string lpvParam , int fuWinIni);
        public const int SPIF_SENDCHANGE = 0x2;
        public const int SPI_SETDESKWALLPAPER = 20;
    }
}

Ich hoffe jemand von euch weis woran es liegt.

Edit:

Das BMP File wird erstellt.
 

Neue Beiträge

Zurück