zoukankan      html  css  js  c++  java
  • 学习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/
    本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。

     
  • 相关阅读:
    Django REST framework
    容器平台自动化CI/CD流水线实操
    VUE--webpack
    vue动态路由匹配
    VUE学习---vue基础与vue-router
    MYSQL-创建测试数据
    MYSQL-主键、外键
    MYSQL-数据库、表、数据操作
    MySQL-添加环境变量 及MySQL服务启停
    MYSQL-命令行
  • 原文地址:https://www.cnblogs.com/GnagWang/p/1773222.html
Copyright © 2011-2022 走看看