# Ruby and COM

**URL:** <https://www.ruby-forum.com/t/ruby-and-com/75789>\
**Category:** Ruby\
**Created:** [November 13, 2006, 2:53pm UTC](https://www.ruby-forum.com/t/ruby-and-com/75789 "2006-11-13T14:53:15Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![buendia](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/54ee81/32.png) [@buendia](https://www.ruby-forum.com/u/buendia)\
**Post date:** [November 13, 2006, 2:53pm UTC](https://www.ruby-forum.com/t/ruby-and-com/75789/1 "2006-11-13T14:53:15Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![buendia](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/54ee81/32.png) [@buendia](https://www.ruby-forum.com/u/buendia)\
**Post date:** [November 13, 2006, 3:22pm UTC](https://www.ruby-forum.com/t/ruby-and-com/75789/2 "2006-11-13T15:22:54Z")

</div>

Aureliano B. 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/](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

---

<div class="post-metadata">

**Author:** ![buendia](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/54ee81/32.png) [@buendia](https://www.ruby-forum.com/u/buendia)\
**Post date:** [November 13, 2006, 3:22pm UTC](https://www.ruby-forum.com/t/ruby-and-com/75789/3 "2006-11-13T15:22:54Z")

</div>

Aureliano B. 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/](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

---

<div class="post-metadata">

**Author:** ![buendia](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/54ee81/32.png) [@buendia](https://www.ruby-forum.com/u/buendia)\
**Post date:** [November 13, 2006, 3:26pm UTC](https://www.ruby-forum.com/t/ruby-and-com/75789/4 "2006-11-13T15:26:55Z")

</div>

Oops… the name of the database should not be inside quotes!

oCn.connectionString = “Provider=sqloledb;Data Source=(local);Initial  
Catalog=northwind;Integrated Security=sspi;”

---

<div class="post-metadata">

**Author:** ![buendia](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/54ee81/32.png) [@buendia](https://www.ruby-forum.com/u/buendia)\
**Post date:** [November 13, 2006, 5:03pm UTC](https://www.ruby-forum.com/t/ruby-and-com/75789/5 "2006-11-13T17:03:19Z")

</div>

On 11/13/06, Aureliano B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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:

> **[Larry Osterman's WebLog](https://learn.microsoft.com/en-us/archive/blogs/larryosterman/)**

---

<div class="post-metadata">

**Author:** ![buendia](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/54ee81/32.png) [@buendia](https://www.ruby-forum.com/u/buendia)\
**Post date:** [November 13, 2006, 3:31pm UTC](https://www.ruby-forum.com/t/ruby-and-com/75789/6 "2006-11-13T15:31:45Z")

</div>

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)

---

<div class="post-metadata">

**Author:** ![buendia](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/54ee81/32.png) [@buendia](https://www.ruby-forum.com/u/buendia)\
**Post date:** [November 13, 2006, 6:33pm UTC](https://www.ruby-forum.com/t/ruby-and-com/75789/7 "2006-11-13T18:33:40Z")

</div>

On 11/13/06, Aureliano B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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.

---

<div class="post-metadata">

**Author:** ![buendia](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/54ee81/32.png) [@buendia](https://www.ruby-forum.com/u/buendia)\
**Post date:** [November 13, 2006, 6:26pm UTC](https://www.ruby-forum.com/t/ruby-and-com/75789/8 "2006-11-13T18:26:51Z")

</div>

Wilson B. 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:  
> [Larry Osterman's WebLog | Microsoft Learn](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.

---

<div class="post-metadata">

**Author:** ![buendia](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/54ee81/32.png) [@buendia](https://www.ruby-forum.com/u/buendia)\
**Post date:** [November 13, 2006, 7:17pm UTC](https://www.ruby-forum.com/t/ruby-and-com/75789/9 "2006-11-13T19:17:54Z")

</div>

On 11/13/06, Aureliano B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > 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.)

---

<div class="post-metadata">

**Author:** ![buendia](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/54ee81/32.png) [@buendia](https://www.ruby-forum.com/u/buendia)\
**Post date:** [November 13, 2006, 6:44pm UTC](https://www.ruby-forum.com/t/ruby-and-com/75789/10 "2006-11-13T18:44:35Z")

</div>

Wilson B. wrote:

> On 11/13/06, Aureliano B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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?

---

<div class="post-metadata">

**Author:** ![buendia](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/54ee81/32.png) [@buendia](https://www.ruby-forum.com/u/buendia)\
**Post date:** [November 15, 2006, 9:31pm UTC](https://www.ruby-forum.com/t/ruby-and-com/75789/11 "2006-11-15T21:31:43Z")

</div>

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
