Help with SystemParametersInfoA fn to SPI_SETDESKWALLPAPER

Started by gibberish, April 25, 2019, 07:36:14 AM

Previous topic - Next topic

gibberish

I need to programmatically set the desktop wallpaper without requiring logout/reboot. I found this superuser article that says it can be done via SystemParametersInfoA  SPI_SETDESKWALLPAPER: https://superuser.com/a/864313/131214 (see 3rd para, the Update bit)

I have examples and have used System.Windows.SystemParameters (many thanks, Tony), but I don't know how to use SystemParametersInfoA.

Could I request a code example to change desktop wallpaper to c:\mypic.jpg?

Thanks!


td

The Consolidated WIL Help file can be, well, very helpful.  Please check out the SysParamInfo function's request 20.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

gibberish

Holy Toledo - I didn't realize that was already there (and I've read the paperback manual cover-to-cover several times, although not for a number of years now). Many thanks, Tony, I should'a realized that WB would allow direct control of this majorly useful catch-all Windows configurator.

Suggestion: For future releases of WB - add a new Hint to [StudioHints] for that function. Checking/Changing the wallpaper is a useful sysadmin task.

For the record, though - just b/c I'm attempting to absorb how to use dotNet directly - how would I access the SystemParametersInfoA functionality directly? For System.Windows.SystemParameters, you demo'd this code:


ObjectClrOption(`useany`, `System.Windows.SystemParameters`)
objWorkArea = ObjectClrNew(`System.Windows.SystemParameters.WorkArea`)
objScrWidth = ObjectClrNew(`System.Windows.SystemParameters.PrimaryScreenWidth`)
objScrHeight = ObjectClrNew(`System.Windows.SystemParameters.PrimaryScreenHeight`)


How would one access the SystemParametersInfoA like that? Say, to get/set the current wallpaper?

td

I am not aware of any FCL class that has a property or method that allows you to change the desktop background image.  Generally, C# coders just use a Win32 API call just like WinBatch does. 

Paper manuals have gone the way of the Dodo bird.  One reason is that computer-based resources are much easier to search.  For example, if you search on "Wallpaper" in the Consolidated WIL Help file, the first two results are the function "WallPaper" and the function "SysParamInfo". 
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade