diff options
author | suke <suke@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-03-16 13:24:06 +0000 |
---|---|---|
committer | suke <suke@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-03-16 13:24:06 +0000 |
commit | 43385dc583124e46a1ea511f3a1e44f7c90e00ba (patch) | |
tree | eafd7873d0e1186caa2df7cfae75cb287f8927db | |
parent | bae81f10bd251e54e1d16d246901912f44b9754e (diff) | |
download | ruby-43385dc583124e46a1ea511f3a1e44f7c90e00ba.tar.gz ruby-43385dc583124e46a1ea511f3a1e44f7c90e00ba.tar.xz ruby-43385dc583124e46a1ea511f3a1e44f7c90e00ba.zip |
* ext/win32ole/win32ole.c: add WIN32OLE#ole_activex_initialize,
a little bit supporting ActiveX control. [ruby-talk:241188]
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@12082 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | ext/win32ole/win32ole.c | 51 |
2 files changed, 55 insertions, 1 deletions
@@ -1,3 +1,8 @@ +Fri Mar 16 22:19:24 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp> + + * ext/win32ole/win32ole.c: add WIN32OLE#ole_activex_initialize, + a little bit supporting ActiveX control. [ruby-talk:241188] + Fri Mar 16 22:16:58 2007 Minero Aoki <aamine@loveruby.net> * lib/net/http.rb: merge Ruby-SSPI patch contributed by Justin diff --git a/ext/win32ole/win32ole.c b/ext/win32ole/win32ole.c index 5d8c59dbf..c63401a7c 100644 --- a/ext/win32ole/win32ole.c +++ b/ext/win32ole/win32ole.c @@ -116,7 +116,7 @@ #define WC2VSTR(x) ole_wc2vstr((x), TRUE) -#define WIN32OLE_VERSION "1.0.1" +#define WIN32OLE_VERSION "1.0.2" typedef HRESULT (STDAPICALLTYPE FNCOCREATEINSTANCEEX) (REFCLSID, IUnknown*, DWORD, COSERVERINFO*, DWORD, MULTI_QI*); @@ -363,6 +363,7 @@ static VALUE ole_usertype2val(ITypeInfo *pTypeInfo, TYPEDESC *pTypeDesc, VALUE t static VALUE ole_ptrtype2val(ITypeInfo *pTypeInfo, TYPEDESC *pTypeDesc, VALUE typedetails); static VALUE ole_typedesc2val(ITypeInfo *pTypeInfo, TYPEDESC *pTypeDesc, VALUE typedetails); static VALUE fole_method_help(VALUE self, VALUE cmdname); +static VALUE fole_activex_initialize(VALUE self); static VALUE foletype_s_ole_classes(VALUE self, VALUE typelib); static VALUE foletype_s_typelibs(VALUE self); static VALUE foletype_s_progids(VALUE self); @@ -4260,6 +4261,53 @@ fole_method_help(VALUE self, VALUE cmdname) } /* + * 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(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, eWIN32OLERuntimeError, "fail to initialize ActiveX control"); + } + + return Qnil; +} + +/* * call-seq: * WIN32OLE_TYPE.ole_classes(typelib) * @@ -7959,6 +8007,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_activex_initialize", fole_activex_initialize, 0); rb_define_method(cWIN32OLE, "ole_type", fole_type, 0); rb_define_alias(cWIN32OLE, "ole_obj_help", "ole_type"); rb_define_method(cWIN32OLE, "ole_typelib", fole_typelib, 0); |