bool IsOk() const { return m_dispatchPtr != NULL; }
// Get a dispatch pointer from the current object associated
- // with a class id, such as "Excel.Application"
- bool GetInstance(const wxString& classId) const;
+ // with a ProgID, such as "Excel.Application"
+ bool GetInstance(const wxString& progId) const;
// Get a dispatch pointer from a new instance of the the class
- bool CreateInstance(const wxString& classId) const;
+ bool CreateInstance(const wxString& progId) const;
// Low-level invocation function. Pass either an array of variants,
// or an array of pointers to variants.
//@}
/**
- Creates a new object based on the class id, returning @true if the object was
+ Creates a new object based on the ProgID, returning @true if the object was
successfully created,
or @false if not.
*/
- bool CreateInstance(const wxString& classId) const;
+ bool CreateInstance(const wxString& progId) const;
/**
Checks if the object is in a valid state.
void* GetDispatchPtr() const;
/**
- Retrieves the current object associated with a class id, and attaches the
- IDispatch pointer
- to this object. Returns @true if a pointer was successfully retrieved, @false
+ Retrieves the current object associated with the specified ProgID, and
+ attaches the IDispatch pointer to this object.
+
+ Returns @true if a pointer was successfully retrieved, @false
otherwise.
Note that this cannot cope with two instances of a given OLE object being
active simultaneously,
such as two copies of Excel running. Which object is referenced cannot
currently be specified.
*/
- bool GetInstance(const wxString& classId) const;
+ bool GetInstance(const wxString& progId) const;
/**
Retrieves a property from this object, assumed to be a dispatch pointer, and
}
// Get a dispatch pointer from the current object associated
-// with a class id
-bool wxAutomationObject::GetInstance(const wxString& classId) const
+// with a ProgID
+bool wxAutomationObject::GetInstance(const wxString& progId) const
{
if (m_dispatchPtr)
return false;
CLSID clsId;
IUnknown * pUnk = NULL;
- wxBasicString unicodeName(classId);
+ wxBasicString unicodeName(progId);
hr = CLSIDFromProgID((BSTR) unicodeName, &clsId);
if (FAILED(hr))
{
- ShowException(classId, hr, NULL, 0);
+ ShowException(progId, hr, NULL, 0);
wxLogWarning(wxT("Cannot obtain CLSID from ProgID"));
return false;
}
hr = GetActiveObject(clsId, NULL, &pUnk);
if (FAILED(hr))
{
- ShowException(classId, hr, NULL, 0);
+ ShowException(progId, hr, NULL, 0);
wxLogWarning(wxT("Cannot find an active object"));
return false;
}
hr = pUnk->QueryInterface(IID_IDispatch, (LPVOID*) &m_dispatchPtr);
if (FAILED(hr))
{
- ShowException(classId, hr, NULL, 0);
+ ShowException(progId, hr, NULL, 0);
wxLogWarning(wxT("Cannot find IDispatch interface"));
return false;
}
}
// Get a dispatch pointer from a new object associated
-// with the given class id
-bool wxAutomationObject::CreateInstance(const wxString& classId) const
+// with the given ProgID
+bool wxAutomationObject::CreateInstance(const wxString& progId) const
{
if (m_dispatchPtr)
return false;
HRESULT hr;
CLSID clsId;
- wxBasicString unicodeName(classId);
+ wxBasicString unicodeName(progId);
hr = CLSIDFromProgID((BSTR) unicodeName, &clsId);
if (FAILED(hr))
{
- ShowException(classId, hr, NULL, 0);
+ ShowException(progId, hr, NULL, 0);
wxLogWarning(wxT("Cannot obtain CLSID from ProgID"));
return false;
}
(void**)&m_dispatchPtr);
if (FAILED(hr))
{
- ShowException(classId, hr, NULL, 0);
+ ShowException(progId, hr, NULL, 0);
wxLogWarning(wxT("Could not start an instance of this class."));
return false;
}