Ruby and COM

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.

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

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

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

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

On 11/13/06, Aureliano B. [email protected] 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

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)

On 11/13/06, Aureliano B. [email protected] 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.

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

On 11/13/06, Aureliano B. [email protected] 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.)

Wilson B. wrote:

On 11/13/06, Aureliano B. [email protected] 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?

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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs