ole_activex_initialize()
public
Initialize WIN32OLE object(ActiveX Control) by
calling IPersistMemory::InitNew.
Before calling
OLE method, some kind of the ActiveX controls created with MFC should be
initialized by calling IPersistXXX::InitNew.
If and only if you received the exception “HRESULT error code: 0x8000ffff
catastrophic failure”, try this method before invoking any ole_method.
obj = WIN32OLE.new("ProgID_or_GUID_of_ActiveX_Control")
obj.ole_activex_initialize
obj.method(...)
Show source
static VALUE
fole_activex_initialize(VALUE self)
{
struct oledata *pole = NULL;
IPersistMemory *pPersistMemory;
void *p;
HRESULT hr = S_OK;
pole = oledata_get_struct(self);
hr = pole->pDispatch->lpVtbl->QueryInterface(pole->pDispatch, &IID_IPersistMemory, &p);
pPersistMemory = p;
if (SUCCEEDED(hr)) {
hr = pPersistMemory->lpVtbl->InitNew(pPersistMemory);
OLE_RELEASE(pPersistMemory);
if (SUCCEEDED(hr)) {
return Qnil;
}
}
if (FAILED(hr)) {
ole_raise(hr, eWIN32OLERuntimeError, "fail to initialize ActiveX control");
}
return Qnil;
}