From: Adam Gardiner Date: 2006-04-10T18:16:28+09:00 Subject: Re: win32ole with COM method taking two out refs Hi Masaki, Masaki Suketa wrote: > Hello, > > In message "Re: win32ole with COM method taking two out refs" > on 06/04/08, Adam Gardiner writes: > >> ... in 'ole_methods': failed to GetTypeInfo (RuntimeError) > It seems to me that your COM server does not provide type library > information to access from WIN32OLE. Looking at the type library, I see you are correct - the method OpenApplication defines the server and session parameters as ppIUnknown. If in VB I define the server and session parameters types as Object, I cannot call any methods on them either. > could you try that the following work or not? > > session = WIN32OLE.new('Hyperion.HsvSession') > obj = session._invoke(0, [], []) > p obj This fails with the following error message: hfm.rb:5:in `_invoke': _invoke (WIN32OLERuntimeError) OLE error code:0 in HRESULT error code:0x80020003 Member not found. from hfm.rb:5 The furthest I seem to be able to get is as follows: server = WIN32OLE.new('Hyperion.HsxClient') session = WIN32OLE.new('Hyperion.HsvSession') OpenApplication cluster, product, app, server, session session = WIN32OLE::ARGV[4] This works without error, but then I get "HRESULT error code:0x80020009 Exception occurred." if I try to call any method on the session object. As an alternative, I've also tried using olegen.rb to generate a Ruby class from the type library. However, I don't seem to be able to pass an object of the right type for my server and session parameters. Here is the generated OpenApplication method: # VOID OpenApplication # method OpenApplication # BSTR arg0 --- bstrClusterName [IN] # BSTR arg1 --- bstrProduct [IN] # BSTR arg2 --- bstrApp [IN] # UNKNOWN arg3 --- ppIUnkServer [OUT] # UNKNOWN arg4 --- ppIUnkSession [OUT] def OpenApplication(arg0, arg1, arg2, arg3, arg4) ret = @dispatch._invoke(13, [arg0, arg1, arg2, arg3, arg4], [VT_BSTR, VT_BSTR, VT_BSTR, VT_BYREF|VT_VARIANT, VT_BYREF|VT_VARIANT]) @lastargs = WIN32OLE::ARGV ret end When I create an instance of this class, I can call other methods prior to OpenApplication without problems, e.g. hfm = Hyperion_HFMClient.new() server = hfm.GetServerOnCluster('HFDEV') session = WIN32OLE.new('Hyperion.HsvSession') hfm.SetLogonInfoSSO('', userid, '', password) hfm.OpenApplication( cluster, product, app, server, session) But the call to OpenApplication returns a type mismatch error no matter what I try to pass in for the server and session parameters: ./hsx_client.rb:164:in `_invoke': _invoke (WIN32OLERuntimeError) OLE error code:0 in HRESULT error code:0x80020005 Type mismatch. from ./hsx_client.rb:164:in `OpenApplication' from hfm2.rb:10 I would have expected this to get at least as far the other code. Any idea why the WIN32OLE._invoke call doesn't like the same parameters that work when I call WIN32OLE.OpenApplication? Sorry to be a bother, but this is really bugging me, and I'd love to be able to use Ruby for this bit of work. Many Thanks, Adam > Regards, > Masaki Suketa -- Posted via http://www.ruby-forum.com/.