• Welcome to Theos PowerBasic Museum 2017.

News:

Attachments are only available to registered users.
Please register using your full, real name.

Main Menu

get event interface with itypelib

Started by Lutfie Ahmad, February 17, 2009, 08:02:39 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Lutfie Ahmad

Hi,
Im a freebasic programmer, impressed by your TypeLib browser, im following link provided in this forum to make a typelib browser. the syntax between PB and FB seem close. I wrote in my typelib documentation credit to you. but it is with tlb32inf.dll.

then someone inform me that vista dont support tlb32inf.dll, so i must switch to use Itypelib to generate code.
So far, via itypelib, I can make code for vtable and invoke, enum constant, record, union, alias. and module.
but im still have no idea to get event interface via itypelib.

if you dont mind, how to get event interface via itypelib in PB?

thank you.

José Roca

#1
Quote
then someone inform me that vista dont support tlb32inf.dll

As far as I know, it only works if you run the application as administrator.

Quote
how to get event interface via itypelib in PB?

To identify event interfaces, if ITypeInfo.GetImplTypeFlags returns 2 or 3 (default event interface), it is an event interface.

The problem is that this information is only available through the CoClass. Therefore, when parsing the type library, if ITypeLib.GetTypeInfoType returns TKIND_COCLASS you have to call ITypeInfo.GetTypeAttr to retrieve a pointer to the TYPEATTR structure and get the number of implemented interfaces looking at the cImplTypes member of this structure. Then you do:


cImplTypes = @pTypeAttr.cImplTypes
FOR x = 0 TO cImplTypes - 1
   lImplTypeFlags = 0
   hr = pITypeInfo.GetImplTypeFlags(x, lImplTypeFlags)
   pRefType = 0
   hr = pITypeInfo.GetRefTypeOfImplType(x, pRefType)
   hr = pITypeInfo.GetRefTypeInfo(pRefType, pImplTypeInfo)
   hr = pImplTypeInfo.GetDocumentation(-1, bstrName, BYVAL %NULL, BYVAL %NULL, BYVAL %NULL)
   IF lImplTypeFlags = 2 OR lImplTypeFlags = 3 THEN    ' // Events interface / Default events interface
      ' Store the name of the event interface for later use
   END IF
NEXT


Lutfie Ahmad

thank you :)
I found some snippet in C, but their syntax beyond my understanding :-(
/* So we've got the dispatch interface; lets list the event methods */
for (i = 0; i < attr->cFuncs; i++) {
zval *tmp;
DISPID lastid = 0; /* for props */
int isprop;

if (FAILED(typeinfo->lpVtbl->GetFuncDesc(typeinfo, i, &func)))
break;

isprop = (func->invkind & DISPATCH_PROPERTYGET || func->invkind & DISPATCH_PROPERTYPUT);

if (!isprop || lastid != func->memid) {


with your snippet I can move again :-)
I hope you will please to help me, when Im here again with question

José Roca

 
The C code that you have posted is meant to retrieve information about the name and parameters of the methods. Mine is to identify which interfaces are event interfaces. Not sure if that is what you wanted.

Lutfie Ahmad

aaah, lucky me, im not translated this code, i just stick to this quote
Quote/* So we've got the dispatch interface; lets list the event methods */
your code is what I wanted :-)

Lutfie Ahmad

#5
Hi Jose,
if you interrested, here is the result of your TLB clone for fb ^_^
http://fbedit.freebasic.net/viewtopic.php?f=6&t=196&start=10

its not finished yet, but the generated code are usable in freebasic, Im still in working to finishing and finding bugs.

José Roca

 
Thanks for letting me know. Writing a COM browser is the best way to learn all the secrets of low-level COM programming.