• Welcome to Theos PowerBasic Museum 2017.

PB COM dll to be used in Excel

Started by Eros Olmi, June 19, 2010, 11:57:25 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Eros Olmi

I'm trying to create a prototype of a COM Dll to be used in Excel (or any COM aware application)
DLL is registered in Windows.
I can browse it with PB COM Browser
I can browse it José TypeLib
I can see in Excel as programming reference but when I try to use it in Excel it GPF as soon as I instanciate a new object.

I must miss something under my nose but after hours I'm not able to find it or maybe I still need to know something.

Any help is appreciated.

Attached full project with sources, dll and VBS + Excel example.
thinBasic Script Interpreter - www.thinbasic.com | www.thinbasic.com/community
Win7Pro 64bit - 8GB Ram - Intel i7 M620 2.67GHz - NVIDIA Quadro FX1800M 1GB

José Roca


Eros Olmi

Thanks a lot José but maybe I gave wrong indication
I'm not particualrly interested in Excel, I'm using Excel just fortesting

The above COM Dll does not work even in a simple VBS script like:
Quoteset objA = CreateObject("thinbasicx")

if IsObject(objA) = False then
  msgbox "Library not loaded"
else
  msgbox "Start sleeping"

  objA.sleep(2000)

  msgbox "End sleeping"

  set objA = Nothing
end if

CreateObject fails immediately.

I have to say I'm under Windows 7 64bit, do not know if this can justify something.

Ciao
Eros
thinBasic Script Interpreter - www.thinbasic.com | www.thinbasic.com/community
Win7Pro 64bit - 8GB Ram - Intel i7 M620 2.67GHz - NVIDIA Quadro FX1800M 1GB

Eros Olmi

Yes, under 32bit OS it seems to work.
thinBasic Script Interpreter - www.thinbasic.com | www.thinbasic.com/community
Win7Pro 64bit - 8GB Ram - Intel i7 M620 2.67GHz - NVIDIA Quadro FX1800M 1GB

Eros Olmi

Recoded a bit and updated attached file in first post.
I can confirm: under Wind 7 64Bit COM Server gives error as soon as I try to instanciate. Under 32bit it works fine
thinBasic Script Interpreter - www.thinbasic.com | www.thinbasic.com/community
Win7Pro 64bit - 8GB Ram - Intel i7 M620 2.67GHz - NVIDIA Quadro FX1800M 1GB

José Roca

 
If VBScript is 64 bit, it can't use 32-bit servers.

Mike Stefanik

There was a discussion about mixing 32-bit and 64-bit code over in the PB forums, such as here. Bottom line, the only way to make a 32-bit COM server work with 64-bit code is it must be out-of-process (i.e.: an ActiveX EXE). A 64-bit process cannot load 32-bit code into its address space.
Mike Stefanik
sockettools.com

Eros Olmi

#7
I installed AutoIt script engine 32bit and it works from VBScript 64 bit.
So I suppose because it is an ActiveX

I analysed both COM Server (AutoIt and my PB COM lib) using José TypeLib browser and, apart the use of capitals letters in COM libs created with PB, the rest is very very similar.

Anyhhow, thanks a lot.
I need to study more on this matter.

Added: it would be nice to have possibility to alias programIDs, interface names, parameters names, ... in order to have them in mixed case.
thinBasic Script Interpreter - www.thinbasic.com | www.thinbasic.com/community
Win7Pro 64bit - 8GB Ram - Intel i7 M620 2.67GHz - NVIDIA Quadro FX1800M 1GB

José Roca

Quote
I installed AutoIt script engine 32bit and it works from VBScript 64 bit.
So I suppose because it is an ActiveX

Doubtful. Maybe the AutoIt installer has installed both a 32-bit and 64-bit versions.

Quote
I analysed both COM Server (AutoIt and my PB COM lib) using José TypeLib browser and, apart the use of capitals letters in COM libs created with PB, the rest is very very similar.

The first function called when a DLL is loaded (and an OCX is a DLL with just a different extesion name) is LIBMAIN:

FUNCTION LIBMAIN(BYVAL hInstance AS DWORD, _
  BYVAL lReason AS LONG, _
  BYVAL lReserved AS LONG) AS LONG

And the first parameter, hInstance, is a DWORD in 32-bit and a QUAD in 64-bit.