太简单的问题了,都不好意思问,但是就搞不定.
刚学COM, 太菜了,不要笑我...
我在一个SDI的InitInstance函数有如下代码:
IActiveDesktop *IAD = NULL;
HRESULT hr;
CString path;
hr = CoCreateInstance(CLSID_ActiveDesktop,
NULL,
CLSCTX_INPROC_SERVER,
IID_IActiveDesktop,
(void**)&IAD
);
if (SUCCEEDED(hr) )
{
IAD->GetWallpaper(path, NULL, 0);
MessageBox(NULL, path, path, MB_OK);
IAD->Release( );
}
在stdafx.h中,加入了
#include""shlobj.h"
#include "COMDEF.H"
编译时老是出现:
C:\Documents and Settings\Administrator.ABC\桌面\com\com.cpp(96) : error C2027: use of undefined type 'IActiveDesktop'
c:\program files\microsoft visual studio\vc98\include\comdef.h(507) : see declaration of 'IActiveDesktop'
C:\Documents and Settings\Administrator.ABC\桌面\com\com.cpp(96) : error C2227: left of '->GetWallpaper' must point to class/struct/union
C:\Documents and Settings\Administrator.ABC\桌面\com\com.cpp(98) : error C2027: use of undefined type 'IActiveDesktop'
c:\program files\microsoft visual studio\vc98\include\comdef.h(507) : see declaration of 'IActiveDesktop'
C:\Documents and Settings\Administrator.ABC\桌面\com\com.cpp(98) : error C2227: left of '->Release' must point to class/struct/union