Ruby and COM

Discussion in 'Ruby' started by Aureliano Buendia, Nov 13, 2006.

  1. Hi,

    Is it possible to use a COM component library in Ruby? The COM consists
    of a dll and a tlb file, it is NOT a .NET assembly, just a standard
    windows COM.

    --
    Posted via http://www.ruby-forum.com/.
    Aureliano Buendia, Nov 13, 2006
    #1
    1. Advertising

  2. Aureliano Buendia

    Jan Svitok Guest

    On 11/13/06, Aureliano Buendia <> wrote:
    > Hi,
    >
    > Is it possible to use a COM component library in Ruby? The COM consists
    > of a dll and a tlb file, it is NOT a .NET assembly, just a standard
    > windows COM.


    It's possible if it is normally registered in the system, i.e. you are
    able to use it from VB, wsh, etc. Have a look at WIN32OLE.
    Jan Svitok, Nov 13, 2006
    #2
    1. Advertising

  3. Aureliano Buendia wrote:
    > Hi,
    >
    > Is it possible to use a COM component library in Ruby? The COM consists
    > of a dll and a tlb file, it is NOT a .NET assembly, just a standard
    > windows COM.
    >
    > --
    > Posted via http://www.ruby-forum.com/.

    Yes. For example...

    require 'win32ole'

    begin

    oCn = WIN32OLE.new("adodb.connection")
    oCn.connectionString = "Provider=sqloledb;Data Source=(local);Initial
    Catalog="northwind";Integrated Security=sspi;"

    oCn.open()
    puts("Connection opened to Northwind database")

    rescue Exeception => ex
    puts(ex.message())

    ensure

    oCn.close() unless oCn.nil?
    oCn = nil

    end
    Patrick Spence, Nov 13, 2006
    #3
  4. Aureliano Buendia wrote:
    > Hi,
    >
    > Is it possible to use a COM component library in Ruby? The COM consists
    > of a dll and a tlb file, it is NOT a .NET assembly, just a standard
    > windows COM.
    >
    > --
    > Posted via http://www.ruby-forum.com/.

    Yes. For example...

    require 'win32ole'

    begin

    oCn = WIN32OLE.new("adodb.connection")
    oCn.connectionString = "Provider=sqloledb;Data Source=(local);Initial
    Catalog="northwind";Integrated Security=sspi;"

    oCn.open()
    puts("Connection opened to Northwind database")

    rescue Exeception => ex
    puts(ex.message())

    ensure

    oCn.close() unless oCn.nil?
    oCn = nil

    end
    Patrick Spence, Nov 13, 2006
    #4
  5. Oops... the name of the database should not be inside quotes!

    oCn.connectionString = "Provider=sqloledb;Data Source=(local);Initial
    Catalog=northwind;Integrated Security=sspi;"
    Patrick Spence, Nov 13, 2006
    #5
  6. Patrick,

    Thanks. WIN32OLE.new needs the PROGID or CLSID, how is it possible to
    find this out from a tlb file? (I know, this is not a Ruby question)

    --
    Posted via http://www.ruby-forum.com/.
    Aureliano Buendia, Nov 13, 2006
    #6
  7. On 11/13/06, Aureliano Buendia <> wrote:
    > Patrick,
    >
    > Thanks. WIN32OLE.new needs the PROGID or CLSID, how is it possible to
    > find this out from a tlb file? (I know, this is not a Ruby question)
    >


    If you don't have Visual Studio (which has a graphical COM browser),
    or something similar, you can look in the registry.
    This post tells you where to look:
    http://blogs.msdn.com/larryosterman/archive/2006/01/10/511279.aspx
    Wilson Bilkovich, Nov 13, 2006
    #7
  8. Wilson Bilkovich wrote:
    > If you don't have Visual Studio (which has a graphical COM browser),
    > or something similar, you can look in the registry.
    > This post tells you where to look:
    > http://blogs.msdn.com/larryosterman/archive/2006/01/10/511279.aspx


    The only place that my tlb is registered is:

    HKEY_LOCAL_MACHINE/SOFTWARE/Classes/TypeLib/{...}/version_number

    where {...} is the CLSID and version_number is the version number. Using

    WIN32OLE.new('{...}')

    does not work as WIN32OLE cannot find this CLSID in the registy. Is this
    a WIN32OLE problem? Maybe it only looks for some other places in the
    registery.


    --
    Posted via http://www.ruby-forum.com/.
    Aureliano Buendia, Nov 13, 2006
    #8
  9. On 11/13/06, Aureliano Buendia <> wrote:
    > Wilson Bilkovich wrote:
    > > If you don't have Visual Studio (which has a graphical COM browser),
    > > or something similar, you can look in the registry.
    > > This post tells you where to look:
    > > http://blogs.msdn.com/larryosterman/archive/2006/01/10/511279.aspx

    >
    > The only place that my tlb is registered is:
    >
    > HKEY_LOCAL_MACHINE/SOFTWARE/Classes/TypeLib/{...}/version_number
    >
    > where {...} is the CLSID and version_number is the version number. Using
    >
    > WIN32OLE.new('{...}')
    >
    > does not work as WIN32OLE cannot find this CLSID in the registy. Is this
    > a WIN32OLE problem? Maybe it only looks for some other places in the
    > registery.
    >


    Are you able to use this COM object from other
    languages/applications/etc? I'm a little rusty, but it doesn't sound
    properly registered to me.
    Wilson Bilkovich, Nov 13, 2006
    #9
  10. Wilson Bilkovich wrote:
    > On 11/13/06, Aureliano Buendia <> wrote:
    >> where {...} is the CLSID and version_number is the version number. Using
    >>
    >> WIN32OLE.new('{...}')
    >>
    >> does not work as WIN32OLE cannot find this CLSID in the registy. Is this
    >> a WIN32OLE problem? Maybe it only looks for some other places in the
    >> registery.
    >>

    >
    > Are you able to use this COM object from other
    > languages/applications/etc? I'm a little rusty, but it doesn't sound
    > properly registered to me.


    The COM object can be used from visual basic 6, so it should be possible
    to be accessed from anywhere else?

    --
    Posted via http://www.ruby-forum.com/.
    Aureliano Buendia, Nov 13, 2006
    #10
  11. On 11/13/06, Aureliano Buendia <> wrote:
    > Wilson Bilkovich wrote:
    > > On 11/13/06, Aureliano Buendia <> wrote:
    > >> where {...} is the CLSID and version_number is the version number. Using
    > >>
    > >> WIN32OLE.new('{...}')
    > >>
    > >> does not work as WIN32OLE cannot find this CLSID in the registy. Is this
    > >> a WIN32OLE problem? Maybe it only looks for some other places in the
    > >> registery.
    > >>

    > >
    > > Are you able to use this COM object from other
    > > languages/applications/etc? I'm a little rusty, but it doesn't sound
    > > properly registered to me.

    >
    > The COM object can be used from visual basic 6, so it should be possible
    > to be accessed from anywhere else?
    >


    In Visual Studio 6, what does the COM browser say that the full name
    is? (It has been a long time, but I think it is F4 or something like
    that.)
    Wilson Bilkovich, Nov 13, 2006
    #11
  12. Aureliano Buendia

    MC Guest

    Hi!

    >>> COM consists of a dll


    DLL... or Exe, or Exe + other extensions, or etc.


    >>> COM consists ... and tlb file


    TLB is only for statics COM-servers ; dynamic COM-servers no have TLB,
    but run OK (by exemple, COM-servers made with Python)

    --
    @-salutations

    Michel Claveau
    MC, Nov 15, 2006
    #12
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    216
  2. anne001
    Replies:
    1
    Views:
    438
  3. Phrogz
    Replies:
    4
    Views:
    227
    Austin Ziegler
    Sep 6, 2006
  4. roschler
    Replies:
    0
    Views:
    179
    roschler
    Oct 16, 2006
  5. Nicholas
    Replies:
    3
    Views:
    384
    Ryan Davis
    Jan 28, 2007
Loading...

Share This Page