1

I'm developing a customized application for personal use on my system. It's a system controller that runs on startup and appears when I press the F1 and F2 keys simultaneously. I initially built it to trigger specific system functionality without needing to dive into the settings every time.

I’d like to add the ability to cycle through desktop backgrounds. Specifically, I want to mimic the functionality of the "Next desktop background" option in the Windows context menu:

Right click desktop context menu with option "Next desktop background" shown

Is there a way to programmatically access this setting in C#?

I already have experience with PInvoke and similar C++ functionality, but I’m still relatively new to this and might need guidance on implementing it properly. What can I try next?

1
  • Hey halfer, I saw your edits. I'm still a bit new to stack and I am curious as to why I should not end a question with a thank you for everyone? Commented Jan 5 at 1:34

1 Answer 1

0

You can use the IDesktopWallpaper.AdvanceSlideshow method, which is a COM interface from the shlobj header, and should be registered in CLSID on your system.

Install CsWin32 NuGet package. Alternatively write up the whole interface manually.

[ComImport]
[Guid("C2CF3110-460E-4FC1-B9D0-8A1C0C9CC4BD")]
public class DesktopWallpaper;
var wallpaper = new DesktopWallpaper();
wallpaper.AdvanceSlideshow(null, 0);
Sign up to request clarification or add additional context in comments.

3 Comments

This sounds good but I think its time for me to move on from C# and into C++. I've wanted to for a long time just been scared of the complexity. No more! I want system customisation!
I suggest you consider Rust....
Rust... I've heard about that. I'm not going to look into it right now until everyone starts touting it as the next language. I am sure it will be soon and I'm keeping my eyes peeled. Looks exciting and powerful.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.