Results 1 to 5 of 5

Thread: Need Code: Upon open, change desktop background

  1. #1

    Thread Starter
    Member
    Join Date
    Jul 2006
    Posts
    41

    Need Code: Upon open, change desktop background

    Hey again all, I been trying to look for this and haven't been successful. Can anyone help me with this code? When you open up the application, the background of your desktop will change. I will provide the .jpg or .gif or .jpeg or .tif file. Thanks ahead of time.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Need Code: Upon open, change desktop background

    I don't know but I would guess that the location of the current desktop wallpaper is stored in the registry. If that's the case then you need to find the key and value it stored under and then what you want to do is just a matter of opening the key and setting the value.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Need Code: Upon open, change desktop background

    Depending on your OS it will be in

    (XP)
    HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes\LastTheme\Wallpaper

    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  4. #4

    Thread Starter
    Member
    Join Date
    Jul 2006
    Posts
    41

    Re: Need Code: Upon open, change desktop background

    ok thxs all.

  5. #5
    Smitten by reality Harsh Gupta's Avatar
    Join Date
    Feb 2005
    Posts
    2,938

    Re: Need Code: Upon open, change desktop background

    Sorry if I am wrong, but if you want to change the wallpaper, yu can use SystemParametersInfo API at Form's load event.
    Code:
    [System.Runtime.InteropServices.DllImportAttribute("user32.dll")]
    		public static extern void SystemParametersInfoA (int uAction, int uParam, string lpvParam, int fuWinIni);
    
    		private const int SPI_SETDESKWALLPAPER = 20;
    		private const int SPIF_UPDATEINIFILE = 0x0001;
    
    		private void Form1_Load(object sender, System.EventArgs e)
    		{
    			SystemParametersInfoA(SPI_SETDESKWALLPAPER, 0, path of image, SPIF_UPDATEINIFILE);
    		}
    Show Appreciation. Rate Posts.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width