COM wrapper data type

  • Thread starter Thread starter Joe Kinsella
  • Start date Start date
J

Joe Kinsella

I'm trying to write a COM wrapper for a COM object for which I do not have a
header file but not a type library. Specifically, I am using NetCon.h to
construct a COM wrapper to give me access to interfaces such as
INetConnectionManager and INetConnection. I have two questions:

1) How can I determine the index of the DispId of the to use for the methods
of the COM object?
2) I have a method that has an out parameter of type pointer to a pointer to
a COM interface (IEnumNetConnection ** ppEnum). I'm a little unsure as to
how or if this can be translated to a .Net COM wrapper?

Any help would be appreciated.

Joe
 
Joe,
1) How can I determine the index of the DispId of the to use for the methods
of the COM object?

These interfaces are derived directly from IUnknown, not dispatch
interfaces, so no DISPIDs are involved.

2) I have a method that has an out parameter of type pointer to a pointer to
a COM interface (IEnumNetConnection ** ppEnum). I'm a little unsure as to
how or if this can be translated to a .Net COM wrapper?

void EnumConnections(NETCONMGR_ENUM_FLAGS Flags, out
IEnumNetConnection ppEnum);

or more conveniently

IEnumNetConnection EnumConnections(NETCONMGR_ENUM_FLAGS Flags);



Mattias
 
Thanks for the reply. So does:

MIDL_INTERFACE("ba126ad1-2166-11d1-b1d0-00805fc1270e")

INetConnectionManager : public IUnknown

{

public:

virtual HRESULT STDMETHODCALLTYPE EnumConnections(

/* [in] */ NETCONMGR_ENUM_FLAGS Flags,

/* [out] */ IEnumNetConnection **ppEnum) = 0;


};



....become...



[ComImport]

[Guid("ba126ad1-2166-11d1-b1d0-00805fc1270e")]

[ClassInterface(ClassInterfaceType.None)]

[TypeLibType(TypeLibTypeFlags.FCanCreate)]

public class INetConnectionManager

{

[MethodImpl(MethodImplOptions.InternalCall,

MethodCodeType=MethodCodeType.Runtime)]

public extern IntPtr EnumConnections( NETCONMGR_ENUM_FLAGS Flags, ref
IEnumNetConnection ppEnum);

}




Addition help is very much appreciated. Thanks again.
 
Joe,

Why do you declare it as a class? I'd make it an interface.

[ComImport]
[Guid("ba126ad1-2166-11d1-b1d0-00805fc1270e")]
[ComInterface(ComInterfaceType.InterfaceIsIUnknown)]
interface INetConnectionManager
{
void EnumConnections(NETCONMGR_ENUM_FLAGS Flags, out
IEnumNetConnection ppEnum);
}



Mattias
 
Back
Top