Xman
驱动大牛
驱动大牛
  • 注册日期2001-08-24
  • 最后登录2011-10-07
  • 粉丝0
  • 关注0
  • 积分343分
  • 威望127点
  • 贡献值0点
  • 好评度34点
  • 原创分0分
  • 专家分0分
阅读:843回复:2

发现MSDN的一个错误!

楼主#
更多 发布于:2004-02-18 18:20
以下摘自MSDN的Using the Active Desktop Object:
HRESULT hr;
IActiveDesktop *pActiveDesktop;

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

//Insert code to call the IActiveDesktop methods

// Call the Release method
pActiveDesktop->Release();

其实pActiveDesktop根本就没有Release()方法!
 :D
[img]http://www.driverdevelop.com/forum/upload/Xman/2004-04-05_2004324183110706.jpg[/img]
xdjm
驱动中牛
驱动中牛
  • 注册日期2001-04-02
  • 最后登录2024-01-25
  • 粉丝0
  • 关注0
  • 积分34分
  • 威望25点
  • 贡献值0点
  • 好评度3点
  • 原创分0分
  • 专家分0分
  • 社区居民
沙发#
发布于:2004-02-18 19:12
以下摘自MSDN的Using the Active Desktop Object:
HRESULT hr;
IActiveDesktop *pActiveDesktop;

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

//Insert code to call the IActiveDesktop methods

// Call the Release method
pActiveDesktop->Release();

其实pActiveDesktop根本就没有Release()方法!
 :D

非也。IActiveDesktop本身确实是没有Release()方法,但是它必须由IUnknown接口继承而来,而Release()方法就是IUnknown接口的函数。
Xman
驱动大牛
驱动大牛
  • 注册日期2001-08-24
  • 最后登录2011-10-07
  • 粉丝0
  • 关注0
  • 积分343分
  • 威望127点
  • 贡献值0点
  • 好评度34点
  • 原创分0分
  • 专家分0分
板凳#
发布于:2004-02-19 12:30
确实如此!

看来我对COM实在太菜。
当时这段程序:

COMPONENT compDesktopItem;
int intCount;
int intIndex = 0;
//Create an instance of the Active Desktop
hr = CoCreateInstance(CLSID_ActiveDesktop, NULL, CLSCTX_INPROC_SERVER,IID_IActiveDesktop, (void**)&pActiveDesktop);
    if(hr!=S_OK)
{
return false;
}
pActiveDesktop->GetDesktopItem(intIndex,&compDesktopItem,0);
//????
/*compDesktopItem.dwSize = sizeof(COMPONENT);
while(intIndex<=(intCount-1))
{
//get the COMPONENT structure for the current desktop item
pActiveDesktop->GetDesktopItem//???(intIndex, &compDesktopItem,0);
//Insert code that processes the structure
//Increment the index
intIndex++;
//Insert code to clean-up structure for next component
}

为何在问号处出错呢???
 :(
[img]http://www.driverdevelop.com/forum/upload/Xman/2004-04-05_2004324183110706.jpg[/img]
游客

返回顶部