views:

155

answers:

1

I have a typelib that describes some interfaces. As some of these interfaces are used as a category, I want to add the category IDs to the typelib. So the question is:

a) how can this be done in Delphi (2007 and up)?

or as an alternative

b) is it possible and advisable to use the interface GUID for the CATID?

+1  A: 

For a), I don't know Delphi. But in C++ it's simply adding the interface description to the MIDL file. As you seem to really only use the interface, you probably do not need a CoClass implementation either, so this would suffice already. Basically, how did you add the other interfaces to the typelib? Do it the same way now.

[edit]I've found a short tutorial on using the typelib-editor. Seems that adding interfaces is only a matter of the correct keyword.[/edit]

As for b), I do not see any problem to use interfaces as a category-id, but this question is a bit vague... As the set of possible categories is fixed, and you do not use some inheritance like behavior (at least I think so as you said you use the interface GUID, not the interface itself), why not just use an enumerator? Using interfaces etc. seems like an over-engineered solution, except if the interfaces are really used as such, i.e. providing access to some category-specific behavior.

[edit]As you're talking about ICatRegister et al., I see why you want to use GUIDs. As the category GUIDs are in a different namespace than the COM interface GUIDs, sure, use the same. Your interface GUIDs need to be unique within the same scope as the category-ids anyhow, and having a 1:1 mapping seems a simple model for maintenance, too.[/edit]

gimpf
a) Delphi has a built-in typelib editor - normally you don't need to edit MIDL files. But if this is the solution - so then.b) I'm actually talking about the component categories that can be handled with ICatRegister and ICatInformation. The idea is to use an established behaviour.
Uwe Raabe
Well, then GUIDs are ok, and don't give up on the typelib-editor just yet. Seems the typelib-editor can do what you want (see link in answer).
gimpf