Ruby and COM

A

Aureliano Buendia

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

Jan Svitok

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

Patrick Spence

Aureliano said:
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.
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
 
P

Patrick Spence

Aureliano said:
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.
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
 
P

Patrick Spence

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

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

Aureliano Buendia

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

Aureliano Buendia

Wilson said:
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.
 
W

Wilson Bilkovich

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

Aureliano Buendia

Wilson said:
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?
 
W

Wilson Bilkovich

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

MC

Hi!

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


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

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top