现在的位置: 首页 > 综合 > 正文

COleVariant

2013年09月07日 ⁄ 综合 ⁄ 共 897字 ⁄ 字号 评论关闭
  1. 使用COleVariant 传递基本数据类型

COleVariant  vTrue(TRUE,VT_BOOL); 

COleVariant  vFalse(FALSE,VT_BOOL);

错误用法,导致构造函数版本不明确.

COleVariant::COleVariant(long,VARTYPE)

COleVariant::COleVariant(short,VARTYPE)

正确用用法,COleVariant opt((long)DISP_E_PARAMNOTFOUND, VT_ERROR);

COleVariant  vFileName((LPCTSTR)pszFilePath);

  1. 使用COleVariant  传递 特殊的参数

COleVariant  vOpt((long)DISP_E_PARAMNOTFOUND, VT_ERROR);//代表可选参数

http://msdn.microsoft.com/en-us/library/bb221597(v=office.12).aspx

msdn的一个例子,expression.SaveAs(FileNameFileFormatLockCommentsPasswordAddToRecentFilesWritePasswordReadOnlyRecommendedEmbedTrueTypeFontsSaveNativePictureFormatSaveFormsDataSaveAsAOCELetterEncodingInsertLineBreaks,AllowSubstitutionsLineEndingAddBiDiMarks)

所有参数都是可选项, 不能够使用c++ 中的默认参数的调用方式,需要:

COleVariant opt((long)DISP_E_PARAMNOTFOUND, VT_ERROR);

doc.SaveAs( &FileName, &FileFormat,opt , opt,\
opt, opt,opt , \
opt, opt,opt,\
opt, opt,opt ,opt, \
opt,opt);

这样调用才行.

抱歉!评论已关闭.