diff --git a/ChangeLog b/ChangeLog index 450b4abf20..88233558c9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Sat Sep 1 08:13:36 2007 Masaki Suketa + + * ext/win32ole/win32ole.c: add WIN32OLE#ole_activex_initialize. + Thu Aug 30 13:13:13 2007 Nobuyoshi Nakada * lib/mkmf.rb (try_const, have_const): check for a const is defined. diff --git a/ext/win32ole/win32ole.c b/ext/win32ole/win32ole.c index a2cac84cb7..767ed98f00 100644 --- a/ext/win32ole/win32ole.c +++ b/ext/win32ole/win32ole.c @@ -79,7 +79,7 @@ #define WC2VSTR(x) ole_wc2vstr((x), TRUE) -#define WIN32OLE_VERSION "0.7.2" +#define WIN32OLE_VERSION "0.7.3" typedef HRESULT (STDAPICALLTYPE FNCOCREATEINSTANCEEX) (REFCLSID, IUnknown*, DWORD, COSERVERINFO*, DWORD, MULTI_QI*); @@ -3261,6 +3261,54 @@ fole_method_help( self, cmdname ) return obj; } +/* + * call-seq: + * WIN32OLE#ole_activex_initialize() -> Qnil + * + * 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 recieved 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(...) + * + */ +static VALUE +fole_activex_initialize(self) + VALUE self; +{ + struct oledata *pole; + IPersistMemory *pPersistMemory; + + HRESULT hr = S_OK; + + OLEData_Get_Struct(self, pole); + + hr = pole->pDispatch->lpVtbl->QueryInterface(pole->pDispatch, &IID_IPersistMemory, + (void **)&pPersistMemory); + if (SUCCEEDED(hr)) { + hr = pPersistMemory->lpVtbl->InitNew(pPersistMemory); + OLE_RELEASE(pPersistMemory); + if (SUCCEEDED(hr)) { + return Qnil; + } + } + + if (FAILED(hr)) { + ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "fail to initialize ActiveX control"); + } + + return Qnil; +} + /* * call-seq: * WIN32OLE_TYPE.ole_classes(typelib) @@ -6162,6 +6210,7 @@ Init_win32ole() rb_define_method(cWIN32OLE, "ole_method", fole_method_help, 1); rb_define_alias(cWIN32OLE, "ole_method_help", "ole_method"); rb_define_method(cWIN32OLE, "ole_obj_help", fole_obj_help, 0); + rb_define_method(cWIN32OLE, "ole_activex_initialize", fole_activex_initialize, 0); rb_define_const(cWIN32OLE, "VERSION", rb_str_new2(WIN32OLE_VERSION)); rb_define_const(cWIN32OLE, "ARGV", rb_ary_new()); diff --git a/version.h b/version.h index 995a649b41..c60e2151e0 100644 --- a/version.h +++ b/version.h @@ -1,15 +1,15 @@ #define RUBY_VERSION "1.8.6" -#define RUBY_RELEASE_DATE "2007-08-30" +#define RUBY_RELEASE_DATE "2007-09-01" #define RUBY_VERSION_CODE 186 -#define RUBY_RELEASE_CODE 20070830 +#define RUBY_RELEASE_CODE 20070901 #define RUBY_PATCHLEVEL 5000 #define RUBY_VERSION_MAJOR 1 #define RUBY_VERSION_MINOR 8 #define RUBY_VERSION_TEENY 6 #define RUBY_RELEASE_YEAR 2007 -#define RUBY_RELEASE_MONTH 8 -#define RUBY_RELEASE_DAY 30 +#define RUBY_RELEASE_MONTH 9 +#define RUBY_RELEASE_DAY 1 #ifdef RUBY_EXTERN RUBY_EXTERN const char ruby_version[];