Click here to Skip to main content
15,886,519 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I wrote a desktop wallpaper program using the
C++
IActiveDesktop
interface. I have also been using Visual Studio 2019 Community Edition as my programing environment. Now I want to make some changes to the wallpaper program and even with including the stated header files for IActiveDesktop (
C++
wininet.h
and
C++
shlopj.h
)
C++
IActiveDesktop *m_pActiveDesktop;
still generates an error. The Microsoft reference indicates that the IActiveDesktop interface is a legacy interface and it seems like it's been replaced with Windows Station and Desktop. However, in the reference material to these things I can find no reference to the desktop wallpaper.

What I have tried:

Can anyone give me an idea of how to access the desktop wallpaper with the new version of Visual Studio 2019?

Much appreciated. Thanks.
Ron
Posted
Updated 23-May-21 7:10am

See IActiveDesktop (shlobj_core.h) - Win32 apps | Microsoft Docs[^]. It would also help if you actually explained what error you see.

[edit]
shlopj.h

The correct header is shlobj_core.h
[/edit]
 
Share this answer
 
v2
Comments
rbrunton 23-May-21 12:40pm    
Sorry for not being clear. I have tried including shlobj_core.h, but it did not resolve the problem. The problem is that IActiveDesktop is not recognized as a valid symbol/class. So, despite including the noted header files - wininet.h first, followed by shlobj_core.h and/or shlobj.h, the compiler (the latest version of VS 2019) generates an error that IActiveDesktop is an unidentified class: "Identifier "IActiveDesktop" is undefined."
Richard MacCutchan 23-May-21 13:02pm    
IActiveDesktop is an interface, so it may need to be instantiated via COM. You need to examine the header file.
I have subsequently looked at using the IDesktopWallpaper interface that I think has superseded the IActiveDesktop and I have been able to successfully change the wallpaper. This requires first:
C++
HRESULT hr = CoInitialize(nullptr);
IDesktopWallpaper* pDesktopWallpaper = nullptr;
hr = CoCreateInstance(__uuidof(DesktopWallpaper), nullptr, CLSCTX_ALL, IID_PPV_ARGS(&pDesktopWallpaper));


and then calls to
C++
pDesktopWallpaper->SetPosition(position);

and
C++
pDesktopWallpaper->SetWallpaper(NULL, lpcwstrFile);

are successful.

(Note: I had the
C++
CoInitialize
and
C++
CoCreateInstance
when trying to work with IActiveDesktop.)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900