Thanks - read the article but it doesn't appear to be the same problem.
I cut and pasted the code that Fordy posted as an answer some time ago to a question regarding IActiveDesktop. The code is below copied directly from the other thread.
Code:
#include <windows.h>//Essential stuff
#include <wininet.h>//This has to be here...bug!!!!!!
#include <shlobj.h>//For IActiveDesktop
#include <comdef.h>//For neat VC++ COM Classes
struct COM_INIT{//To manage COM
COM_INIT(){CoInitialize(0);}
~COM_INIT(){CoUninitialize();}
}COM_INIT_;
int WINAPI WinMain(HINSTANCE hInst,HINSTANCE,LPSTR,int){
char szFile[MAX_PATH+1] = {0};
OPENFILENAME ofn = {sizeof(OPENFILENAME)};
ofn.hInstance = GetModuleHandle(0);
ofn.lpstrFilter = "BMP\0*.BMP\0JPeg\0*.JPG\0Gif\0*.GIF\0";
ofn.lpstrFile = szFile;
ofn.nMaxFile = MAX_PATH+1;
ofn.lpstrTitle = "Pick Bitmap, JPeg or Gif to replace wallpaper";
if(!GetOpenFileName(&ofn))return 0;
try{
WALLPAPEROPT wpo = {sizeof(wpo),WPSTYLE_STRETCH};
_com_ptr_t<_com_IIID<IActiveDesktop,
&__uuidof(IActiveDesktop)> > lpIAD;
lpIAD.CreateInstance(CLSID_ActiveDesktop);
lpIAD->SetWallpaper(_bstr_t(szFile),0);
lpIAD->SetWallpaperOptions(&wpo,0);
lpIAD->ApplyChanges(AD_APPLY_ALL);
MessageBox(0,"Wallpaper changed","",MB_OK);
}
catch(_com_error& e){
MessageBox(0,(e.Description().length() ?
e.Description() : "COM Error"),0,MB_OK);
}
return 0;
}
The following are the errors I get when compiling (I have also added the preprocessor directive as described in the MSDN article.)
main.cpp(29): error C2787: 'IActiveDesktop' : no GUID has been associated with this object
main.cpp(29): error C3203: '_com_IIID' : class template invalid as template argument for template parameter '_IIID', expected a real type
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\comip.h(62): error C2825: '_IIID::Interface': cannot form a qualified name
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\comip.h(62): error C2039: 'Interface' : is not a member of 'operator``global namespace'''
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\comip.h(62): fatal error C1507: previous user errors and subsequent error recovery halt further compilation
Are there any specific project settings I need to implement here?