From: Corey Lawson Date: 2005-07-01T03:05:20+09:00 Subject: Re: win32ole object creation failure This URL probably has what looks like some good info on using Win32API: http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/32861 On 6/30/05, Corey Lawson wrote: > Hmm... I found a chunk of VB code here > http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=12394&lngWId=1 > (look in the ComDlgEx.cls file) that shows what you need to do in VB > to use comdlg32.dll. > > In Ruby, it looks like you can then use this via: > > require 'WIN32API' > > #If you don't have "Pickaxe" (see p 755) then... > > require 'Win32API' > comdlgFileOpen = Win32API.new("comdlg32.dll", "GetOpenFileNameA", ['P'], 'L') > > #...and it goes downhill from there. You basically have to make a > (sorry for the C syntax) > struct OPENFILENAME { > ... > } > #what is the ruby syntax for defining a struct? > > #then use pack() and unpack() to smoosh and unsmoosh things > > ofn = OPENFILENAME > > res = comdlgFileOpen.Call(ofn) > > #in the ofn instance of the OPENFILENAME struct, you set all sorts of > settings for the > #dialog, including file name patterns, etc. > > It looks to be pretty messy, but it's messy for everyone not using > C++, unless your lang (i.e., Delphi) provides nice encapsulations of > the API calls... > > Pickaxe also mentions that > require 'dl/win32' > might be a bit more mature. Maybe it's easier to use? > > > > On 6/30/05, gregarican wrote: > > Axel wrote: > > > > > When I run this (on Windows XP with the Windows Ruby installation > > > package 1.8.2-15), I get the following error: > > > > > > > > > C:/temp/bla.rb:3:in `initialize': Failed to create WIN32OLE object from > > > `MSComDlg.CommonDialog' (WIN32OLERuntimeError) > > > HRESULT error code:0x80040112 > > > Class is not licensed for use from C:/temp/bla.rb:3:in `new' > > > from C:/temp/bla.rb:3 > > > > I get the same result running this on a Windows 2000 box under Ruby > > 1.8.2. Googling around for this Windows API entry it appears as if it > > should be referenced directly using VB and isn't readily available > > through scripting means. At least this URL makes it seem as such --> > > http://www.autoitscript.com/forum/index.php?s=58aec18875ef9a11f9d1b2af990a92c2&showtopic=11379&pid=80340&st=0&#entry80340. > > > > > > >