1。如何知道程序运行时的系统是否使用了ActiveDesktop?2。在使用了ActiveDesktop时,又如何设置墙纸?#include <wininet.h>
#include <shlobj.h>HRESULT hr;
CoInitialize(NULL);
IActiveDesktop *pActiveDesktop;     //编译不通过,IActiveDesktop 不能识别hr = CoCreateInstance(CLSID_ActiveDesktop,
                      NULL,
                      CLSCTX_INPROC_SERVER,
                      IID_IActiveDesktop,
                      (void**)&pActiveDesktop);if(pActiveDesktop->SetWallpaper(L"wallpaper.bmp",0)!=S_OK)
    return;

pActiveDesktop->ApplyChanges(AD_APPLY_ALL|AD_APPLY_FORCE);pActiveDesktop->Release();
CoUninitialize();请高手指点,多谢了

解决方案 »

  1.   

    SystemParametersInfo(SPI_SETDESKWALLPAPER,0,"e:\\xp1.bmp",WM_WININICHANGE);
    可以设置墙纸。
      

  2.   

    要这样声明
    CComQIPtr<IActiveDesktop> pIActiveDesktop;如果要更详细的资料,msdn上有个例子testad,你可以去下载来看看.
    地址http://msdn.microsoft.com/msdnmag/issues/01/05/code/CQA0105.exe
      

  3.   

    多谢二位,那么又如何得知 系统是否使用了 ActiveDesktop 呢?
      

  4.   

    你看的文章是vckbase上面的“com编程入门"吧,要看你是什么操作系统,好像在桌面右健的属性里面能够看到。
      

  5.   

    我是说如何用程序判断系统是否使用了 ActiveDesktop , 能回答这个问题的,另给50分
      

  6.   

    今天有人能谈谈么?如何在程序中判断系统是否使用了ActiveDesktop?
      

  7.   

    ////////////////////////////////////////////////////////////////
    // MSDN Magazine -- May 2001
    // If this code works, it was written by Paul DiLascia.
    // If not, I don't know who wrote it.
    // Compiles with Visual C++ 6.0. Runs on Win 98 and probably Win 2000 too.
    //
    #pragma once#include <atlbase.h> // ATL smart pointers
    #include <shlguid.h> // shell GUIDs
    #include <shlobj.h> // IActiveDesktop//////////////////
    // Handy class to enable/disable Active Desktop. This class wraps only the
    // IActiveDesktop functions needed to enable/disable and get the enabled
    // status. You could improve it to encapsulate all of IActiveDesktop.
    //
    class CActiveDesktop {
    protected:
    // ATL smart pointers are the only way to go!!
    CComQIPtr<IActiveDesktop> m_pIActiveDesktop;public:
    HRESULT m_hr; // most recent return code // ctor: create IActiveDesktop interface instance
    // 
    CActiveDesktop() {
    m_hr = m_pIActiveDesktop.CoCreateInstance(CLSID_ActiveDesktop,
    NULL, CLSCTX_INPROC_SERVER);
    // If this bombs, you probably forgot to call call CoInitialize
    ASSERT(SUCCEEDED(m_hr));
    } // Determine if Active Desktop is enabled. SHGetSettings is apparently
    // more reliable than IActiveDesktop::GetDesktopItemOptions, which can
    // report incorrectly during the middle of ApplyChanges!
    // 
    BOOL IsEnabled() {
    SHELLFLAGSTATE shfs;
    SHGetSettings(&shfs, SSF_DESKTOPHTML);
    return shfs.fDesktopHTML;
    }

    // Enable/disable Active Desktop.
    // Calls ApplyChanges to make it really happen.
    //
    void Enable(BOOL bEnable) {
    ASSERT(m_pIActiveDesktop);
    COMPONENTSOPT opt;
    opt.dwSize = sizeof(opt);
    opt.fActiveDesktop = opt.fEnableComponents = bEnable;
    m_hr = m_pIActiveDesktop->SetDesktopItemOptions(&opt,0);
    ASSERT(SUCCEEDED(m_hr));
    ApplyChanges(AD_APPLY_REFRESH); // do it!
    } // Apply the changes
    //
    void ApplyChanges(DWORD dwFlags) {
    ASSERT(m_pIActiveDesktop);
    m_hr = m_pIActiveDesktop->ApplyChanges(dwFlags);
    ASSERT(SUCCEEDED(m_hr));
    };
    };
      

  8.   

    仍然出错:
    CComQIPtr<IActiveDesktop> m_pIActiveDesktop;  //IActiveDesktop不能被识别
      

  9.   

    可能是什么宏没有定义,我加了_WININET_,错误数从10个减少到5个,可能还有什么宏要定义,请高手指点,多谢了!!!
      

  10.   

    你去下msdn那个例子,如果还不能编译,可能要升级你的vc6的头文件了,或者用7.0编译.地址http://msdn.microsoft.com/msdnmag/issues/01/05/code/CQA0105.exe
      

  11.   

    http://expert.csdn.net/Expert/topic/1277/1277612.xml?temp=.4518244