COM Server

COM Server

I am developing a Fortran COM server for my VB client. I would like to provide an enum as a parameter in one of my methods. The Fortran COM Wizard unfortunate doesn't support this.

I did get it to partially work by modifying the idl file to include my typedef with uuid which contained my enum. This exposed the enum to the VB client, no problem.

I changed the IDispatch method's variable to the enum name. The VB client now could see variable was of my enum type, no problem.

However the intellisense does not pop up a list of valid enum names.
This is the problem, I want my clients to be able to pick from a valid list of values.

Is there some example code that shows how to implement this functionality. I can't find very much in the help file about enum in COM servers.

Thanks In Advance,
CM

4 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Are you using a tag with your typedef? You should have something like :

 
typedef [v1_enum] enum Mycolors	 
{ 
   jtRed=0, 
   jtGreen=1, 
   jtBlue=2, 
} Mycolors; 

hth,
John

Hi,

I just tried:

typedef enum tagFOOE {
FOOE_0 = 0,
FOOE_1 = 1,
} FOOE;

// Interfaces for Foo
[
object,
uuid(E3DCE7A6-DDA3-11D4-8096-0090000478FE) ,
oleautomation ,
dual
]
interface IFoo : IDispatch {
[id(1)] HRESULT M1 (
[in] FOOE Arg1);
};

And the enum values showed up in VB intellisense.

I'll add defining enums to the wizard "wish list".

Leo

A couple things that may or may not be obvious,

When the enum name (tag) and the typedef'd name are different, both names will show up in the type library and in the VB Object Browser. So, for example in the prior posts, both tagFOOE and FOOE would show up as enums in the VB Object Browser in one case, but only MyColors would show up in the other.

Also, if you are using the MIDL generated proxy/stub with DCOM, the MIDL docs mention that the default DCOM wire representation for enums is 16-bit integers; use the [v1_enum] IDL attribute to change this to 32-bit. I always add it out of habit.

The grunge of mapping IDL to type libraries and the fact that there even exists these two formats for representing type information in COM and that there is a loss of fidelity between the two are all fixed in .NET (see .NET metadata and reflection)

hth,
John

Leave a Comment

Please sign in to add a comment. Not a member? Join today