1.在“stdafx.h”中,在
#include <afxwin.h> // MFC 核心和标准组件
#include <afxext.h> // MFC 扩展
#include <afxdisp.h> // MFC 自动化类
前面加上
#include <afx.h>
#include <wininet.h>
这两个头文件顺序不可颠倒
即:
#include <afx.h>
#include <wininet.h>
#include <afxwin.h> // MFC 核心和标准组件
#include <afxext.h> // MFC 扩展
#include <afxdisp.h> // MFC 自动化类
2.使用 CoInitialize(NULL) 和 CoUninitialize() 初始化和终止 COM 使用环境。
3.在使用了 ATL COM 接口的源文件头部,包含声明该 ATL COM 接口的头文件即可。
IActiveDesktop =》#include <shlobj.h>
一个使用 ATL COM 的例子:
BOOL CSystemSet::SetWallPaper(CString strImaglePath, DWORD dwStyle)
{
CoInitialize(NULL);
BOOL bRet = FALSE;
HRESULT hr = S_FALSE;
IActiveDesktop* pIAD = NULL