code_junkie

Passing optional arguments to a COM function in VC++

Nov 13th, 2011
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. CComVariant vFalse = false;
  2. CApplication application;
  3.  
  4. {
  5. application.CreateDispatch(_T("Word.Application"));
  6.  
  7. CDocuments documents = application.get_Documents();
  8.  
  9. CComVariant vFilename = _T("c:\temp\test.rtf");
  10. CComVariant vNothing;
  11. CComVariant vEmpty = _T("");
  12. CComVariant vOpenFormat = 0;
  13. application.put_Visible(TRUE);
  14.  
  15. //
  16. // THIS FUNCTION has a number of optional arguments
  17. //
  18. LPDISPATCH pDocument = documents.Open(&vFilename, &vFalse, &vFalse, &vFalse, &vEmpty, &vEmpty, &vFalse, &vEmpty, &vEmpty, &vOpenFormat, &vOpenFormat, &vFalse, &vFalse, &vOpenFormat, &vFalse, &vFalse);
  19. }
  20. application.Quit(&vFalse, NULL, NULL);
  21.  
  22. CComVariant vtOptional;
  23. vtOptional.vt = VT_ERROR;
  24. vtOptional.scode = DISP_E_PARAMNOTFOUND;
  25.  
  26. _variant_t vtEmpty(VT_EMPTY);
Add Comment
Please, Sign In to add comment