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:
HRESULT hr = CoInitialize(nullptr);
IDesktopWallpaper* pDesktopWallpaper = nullptr;
hr = CoCreateInstance(__uuidof(DesktopWallpaper), nullptr, CLSCTX_ALL, IID_PPV_ARGS(&pDesktopWallpaper));
and then calls to
pDesktopWallpaper->SetPosition(position);
and
pDesktopWallpaper->SetWallpaper(NULL, lpcwstrFile);
are successful.
(Note: I had the
CoInitialize
and
CoCreateInstance
when trying to work with IActiveDesktop.)