• 学习Com[二]


    看了看MSDN里的一个关于IActiveDesktop例子:

    // ActiveDesktopTest.cpp : Defines the entry point for the console application.
    //

    #include "stdafx.h"
    #include <Objbase.h>

    #include <Unknwn.h>
    #include <Shlobj.h>
    #include <iostream>

    int _tmain(int argc, _TCHAR* argv[])
    {

        HRESULT hr = NULL;
       
        CoInitialize(NULL);

        IActiveDesktop *pActiveDesktop;

        //Create an instance of the Active Desktop
        hr = CoCreateInstance(CLSID_ActiveDesktop, NULL, CLSCTX_INPROC_SERVER,
            IID_IActiveDesktop, (void**)&pActiveDesktop);

       
        WCHAR   wszWallpaper [MAX_PATH];
        if (SUCCEEDED(hr))
        {
            pActiveDesktop->GetWallpaper(wszWallpaper, MAX_PATH, 0);

            std::wcout << L"Wallpaper path is:\n    " << wszWallpaper << std::endl;
        }

        pActiveDesktop->Release();

        CoUninitialize();
        return 0;
    }

    在过程中同样出现了很多人遇到的编译不过的问题, 然后在stdafx.h 头文件里添加:

    #include <Windows.h>
    #include <wininet.h>
    #include <stdio.h>

    运行结果:

    Untitled

     


    作者:GangWang
    出处:http://www.cnblogs.com/GnagWang/
    本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。

     
  • 相关阅读:
    LightOJ 1139 8 puzzle + hdu 1043 Eight A*
    hdu 1180 优先队列 + bfs
    hdu 1270
    HDU Doing Homework
    hdu 1171 Big Event in HDU
    hdu 3613 (KMP)回文串
    POJ 3461 Oulipo(KMP)
    POJ 1565(DP状态压缩)
    NYOJ 634 万里挑一(优先队列)
    职场手记1_你想成文什么样的人
  • 原文地址:https://www.cnblogs.com/GnagWang/p/1773222.html
Copyright © 2020-2023  润新知