// Get the value of the "Text" property from a control VARIANT varText; OlePropertyGet(pControl, DISPID_TEXT, &varText); // Convert the variant value to a string CString strText = COleVariant(varText).operator LPCTSTR();
// Get the value of the "Pages" property from a document VARIANT varPages; OlePropertyGet(pDocument, DISPID_PAGES, &varPages); // Convert the variant value to an integer int nPages = COleVariant(varPages).intVal;In this example, we're using the OlePropertyGet function to get the value of the "Pages" property from a document (specified via the pDocument parameter). We pass in the DISPID_PAGES constant to specify the ID of the "Pages" property. The value of the property is returned in a VARIANT variable called varPages. We then convert the variant value to an integer so that we can use it in our application. Package/Library: This function is a part of the MFC (Microsoft Foundation Classes) library, which is a C++ library that provides a framework for developing Windows-based applications. The OlePropertyGet function is specifically used in MFC applications that use COM.