Domanda

Im facendo una semplice wallpaper changer. Funziona quando si cambia la carta da parati, ma non posso cambiare il modello della carta da parati. Ho provato qualcosa di simile, ma doesnt lavoro: S

SystemParametersInfo(SPI_SETDESKPATTERN, 0, "Center",
SPIF_UPDATEINIFILE | SPIF_SENDWININICHANGE);

Può some1 si prega di mostrarmi il modo corretto di impostare la carta da parati?

È stato utile?

Soluzione

Presumo si intende il streched impostazione incentrata / / piastrelle che sarebbe il secondo valore passato int 1-3

[DllImport("user32.dll", CharSet = CharSet.Auto)]
        private static extern Int32 SystemParametersInfo(UInt32 action, UInt32 uParam, String vParam, UInt32 winIni);
        private static readonly UInt32 SPI_SETDESKWALLPAPER = 0x14;
        private static readonly UInt32 SPIF_UPDATEINIFILE = 0x01;
        private static readonly UInt32 SPIF_SENDWININICHANGE = 0x02;

        private void SetWallpaper(string path)
        {
            if (File.Exists(path))
            {
                Image imgInFile = Image.FromFile(path);
                try
                {
                    imgInFile.Save(SaveFile, ImageFormat.Bmp);
                    SystemParametersInfo(SPI_SETDESKWALLPAPER, 3, SaveFile, SPIF_UPDATEINIFILE | SPIF_SENDWININICHANGE);
                }
                catch
                {
                    MessageBox.Show("error in setting the wallpaper");
                }
                finally
                {
                    imgInFile.Dispose();
                }
            }
        }
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top