// this pDispatch will be released by the smart pointer, so use FALSE
COleDispatchDriver DocProperties(pDispatch, FALSE);
_variant_t Property((long)Word::wdPropertyPages);
_variant_t Result;
// The Item method is the default member for the collection object
DocProperties.InvokeHelper(DISPID_VALUE,
DISPATCH_METHOD | DISPATCH_PROPERTYGET,
VT_VARIANT,
(void*)&Result,
(BYTE*)VTS_VARIANT,
&Property);
// pDispatch will be extracted from variant Result
COleDispatchDriver DocProperty(Result);
// The Value property is the default member for the Item object
DocProperty.GetProperty(DISPID_VALUE, VT_I4, &PageCount);
// The page count is now in PageCount
自动化信息能在下列的微软知识库文章中找出:
Q181845 : Create a Sink Interface in MFC-Based COM client
Q183599 : Catch Microsoft Word97 Application Events Using VC++
Q152087 : Connpts.exe Implements Connection Poitns in MFC Apps
Q179494 : Use Automation to Retrieve Built-in Document Properties
Q183369 : Use Automation to Run a Word 97 Macro with Arguments