COMate - control COM objects via automation - OBSOLETE!

Developed or developing a new product in PureBasic? Tell the world about it.
User avatar
Sveinung
Enthusiast
Enthusiast
Posts: 142
Joined: Tue Oct 07, 2003 11:03 am
Location: Bergen, Norway

Post by Sveinung »

@Glops
Are you using PB 4.20? I got the same error when I tested it on 4.10

Regards
Sveinung
glops
User
User
Posts: 38
Joined: Wed Jan 16, 2008 12:53 pm
Location: France

thanks

Post by glops »

Thx Sveinung, I checked and was still runing PB 4.2 beta 4...I updated PB to the official 4.2..and now it is ok :D
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Kiffi wrote:Hello srod,

i have a curious problem. I want to create a TypeLibInfo-Object
(TlbInf32.dll). The DLL ist registered.

But COMate_CreateObject() returns 0 and
COMate_GetLastErrorDescription() says everything is OK:

Code: Select all

TLITypeLibInfo.COMateObject

TLITypeLibInfo = COMate_CreateObject( "TLI.TypeLibInfo" )

If TLITypeLibInfo = 0
  If COMate_RegisterCOMServer("C:\WINDOWS\system32\TlbInf32.dll") = #S_OK
    blnRegister = #True
    TLITypeLibInfo = COMate_CreateObject( "TLI.TypeLibInfo" )
  EndIf
EndIf

Debug COMate_GetLastErrorDescription() ; -> Okay

Debug TLITypeLibInfo ; -> 0 
In VB6 there is no problem:

Code: Select all

Dim tliTypeLibInfo As TypeLibInfo
Set tliTypeLibInfo = New TypeLibInfo ' works
TIA & Greetings ... Kiffi
Well I downloaded a copy of the dll, registered it okay, but my oleviewer and interface generator programs do not show a program.id of TLI.TypeLibInfo at all!

Does it work with PureDispHelper?

**EDIT : doesn't work here with PureDispHelper. Perhaps this dll does not function correctly on Vista! Let me try XP. ---Nope, same problem. Not sure there's much I can do.
I may look like a mule, but I'm not a complete ass.
User avatar
Kiffi
Addict
Addict
Posts: 1485
Joined: Tue Mar 02, 2004 1:20 pm
Location: Amphibios 9

Post by Kiffi »

srod wrote:but my oleviewer and interface generator programs do not show a program.id of TLI.TypeLibInfo at all!
vbAccelerator provides an ActiveX Documenter.
With this tool, the members of TlbInf32.dll can be listed.

http://www.vbaccelerator.com/home/VB/Ut ... rticle.asp

... strange!

Greetings ... Kiffi
Hygge
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

I've looked inside the dll and the only prog.id listed comes up (vista and xp) as "TLI, TypeLib Information" which is pretty much garbage! I can see all the dispinterfaces however!

Can you e-mail me your copy of the dll?

I'll be away for a few hours now but I'll have a look when I get back.
I may look like a mule, but I'm not a complete ass.
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post by ts-soft »

I can only found a ClassID: {8B217746-717D-11CE-AB5B-D41203C10000}
You can use the OCX_CreateGadget as example of using with ClassID,
without ProgramID. (not tested)
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Right, let me modify COMate to accept a CLSID in string form and then I'll have another crack at the dll! :)
I may look like a mule, but I'm not a complete ass.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

@Kiffi : there was a bug in COMate causing the HRESULT value to not be reported in this case. I am now getting a CLASS_E_NOAGGREGATION error code which I shall investigate. :)

**EDIT : no luck.

However, looking at that VB code you posted above, you do realise that that code doesn't use automation don't you?
Using a specified type in the line

Code: Select all

Dim tliTypeLibInfo As TypeLibInfo
will cause Visual Basic to use the underlying vtables to access member functions etc. Admittedly the vtables will be extrapolated from the underlying type library.

I don't know if this is pertinent to the problem here?

What you need to do is try :

Code: Select all

Dim tliTypeLibInfo As Object
Set tliTypeLibInfo = CreateObject("TypeLibInfo")
I may look like a mule, but I'm not a complete ass.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

@Kiffi : found the problem; it is a class factory issue. I have a fix for it, but it will take an hour or so to fully check out. :)
I may look like a mule, but I'm not a complete ass.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Update - version 1.1.4. 10th Sept. 2008.
Version 1.1.4 fixes a bug with the COMate_CreateObject() function which would not set the appropriate error fields under certain circumstances.

Problems interfacing with Microsoft's "TypeInfoLib" library also necessitated the following change:
  • ProgID's can now contain CLSIDs (class identifiers) in string form. These must be placed in braces; e.g. {8B217746-717D-11CE-AB5B-D41203C10000}. These are for those objects not exposing a 'friendly name' (of which the damn TypeInfoLib appears to be one such!)
See the nxSoftware site for the download.

==============================

@Kiffi : As I indicated above, the problems with the TypeInfoLib stemed from the classfactory which was refusing to return the requested interface. Couple this with the fact that the TypeInfoLib doesn't seem to export a friendly-name (progID) and I begin to see why VB uses the Vtables to get at the underlying methods with this particular component! :)

The changes I have made with COMate 1.1.4 fix these issues and the following code runs fine here with the dll you sent me (Vista) :

Code: Select all

IncludePath "..\"
XIncludeFile "COMate.pbi"

TypeInfoLibCLSID$ = "{8B217746-717D-11CE-AB5B-D41203C10000}"

TLITypeLibInfo.COMateObject 
TLITypeLibInfo = COMate_createObject(TypeInfoLibCLSID$) 

If TLITypeLibInfo
  TLITypeLibInfo\SetProperty("ContainingFile = 'tlbinf32.dll'")
  Debug TLITypeLibInfo\GetStringProperty("ContainingFile")
  TLITypeLibInfo\Release()
EndIf
I left out the code for registering the server.

The CLSID (which ts-soft identified) can be located easily enough with MS's OleViewer program. :) I hope this helps.
Last edited by srod on Thu Sep 11, 2008 1:01 pm, edited 1 time in total.
I may look like a mule, but I'm not a complete ass.
SFSxOI
Addict
Addict
Posts: 2970
Joined: Sat Dec 31, 2005 5:24 pm
Location: Where ya would never look.....

Post by SFSxOI »

How timely this update was. I just happen to have something i'm starting on where this particular update might be needed. Thanks srod! :)

When WMI returns a date it looks something like this ; 20080910144149.000000-300. Then send it thru something to change it into some readable.

There is a method to convert those with WMI to normal people-easy-readable dates and times with WMI scripting here: http://msdn.microsoft.com/en-us/library ... S.85).aspx

I was wondering if this could be added to Comate as a method. A single command like maybe a GetDateTimeProperty(command.s)?
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

I don't know about that. I'm not really that keen to add more methods to COMate unless they are related to it's 'core business'.

What you can easily do of course is use COMate to create a SWbemDateTime object and then take it from there. It would be straight forward to create a 'helper file' to wrap this object in etc. Not sure I'll be doing it though! :wink:
I may look like a mule, but I'm not a complete ass.
User avatar
Kiffi
Addict
Addict
Posts: 1485
Joined: Tue Mar 02, 2004 1:20 pm
Location: Amphibios 9

Post by Kiffi »

srod wrote:The CLSID (which ts-soft identified) can be located easily enough with MS's OleViewer program. :)
pffft! I don't need MS's OleViewer program. Now i am able to write my own. :D

Many thanks!!! Image

Greetings ... Kiffi
Hygge
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Ah, I was wondering if that is what you were doing? :) I'd be interested in seeing that.
I may look like a mule, but I'm not a complete ass.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Update - version 1.1.5. 11th Sept. 2008.
Version 1.1.5 fixes a bug related to the changes in version 1.1.4. Doh!!! Basically if using a CLSID in string form, COMate would sometimes fail in it's check to see if this represented a registered component or not! Double-doh!!!

See the nxSoftware site for the download.
I may look like a mule, but I'm not a complete ass.
Post Reply