+ -
当前位置:首页 → 问答吧 → 编译时出现提示:Undefined symbol '_variant_t',为何?

编译时出现提示:Undefined symbol '_variant_t',为何?

时间:2011-12-11

来源:互联网

用到如下代码,编译时出现提示:Undefined symbol '_variant_t',为何?加入头文件COMUTIL.H,链接时又出现问题
HRESULT GetOptions(IHTMLSelectElement *ppvSelect, BSTR *pszOptText, long *plItems)
{
  IDispatch *ppvdispOption;
  IHTMLOptionElement *ppvOption;
  HRESULT hResult;
 
  // Obtain the number of option objects in the select object.
  ppvSelect->get_length(plItems);
 
  for (long i=0;i<*plItems;i++){
 
  // Get an IDispatch interface for the next option.
  _variant_t index = i;
  hResult = ppvSelect->item( index, index, &ppvdispOption );
  if FAILED(hResult) return(hResult);
 
  // Query for the IHTMLOptionElement interface.
  hResult = ppvdispOption->QueryInterface( IID_IHTMLOptionElement, 
  (void **) &ppvOption);
  ppvdispOption->Release();
  if FAILED(hResult) return(hResult);
 
  // Add the option text to a list box.
  hResult = ppvOption->get_text(&(pszOptText[i]));
  ppvOption->Release();
  if FAILED(hResult) return(hResult);
  }
  return S_OK;
}

作者: xdxwb001   发布时间: 2011-12-11

将_variant_t换成VARIANT就行了。

作者: ccrun   发布时间: 2011-12-11