Multimobile Development: Building Applications for any Smartphone
COM wrapper data type
Messages   Related Types
This message was discovered on microsoft.public.dotnet.framework.


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

Reply to this message...
Vote that this is a GOOD answer...
 
Really good experience at the Apple Store
MonoDroid – looking *awesome*
 
    
Mattias Sjögren
Joe,

[Original message clipped]

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

[Original message clipped]

void EnumConnections(NETCONMGR_ENUM_FLAGS Flags, out
IEnumNetConnection ppEnum);

or more conveniently

IEnumNetConnection EnumConnections(NETCONMGR_ENUM_FLAGS Flags);

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Reply to this message...
Vote that this is a GOOD answer...
 
First volume of Multimobile Development nearly ready to go to press
A mention on Developing for the iPhone and Android: The pros and cons
 
    
Joe Kinsella
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.

Reply to this message...
Vote that this is a GOOD answer...
 
 
    
Mattias Sjögren
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

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Reply to this message...
Vote that this is a GOOD answer...
 
First chapters of Multimobile Development book now available on Apress Alpha program
iPad
 
 
System.IntPtr
System.Runtime.CompilerServices.MethodCodeType
System.Runtime.CompilerServices.MethodImplOptions
System.Runtime.InteropServices.ClassInterfaceType
System.Runtime.InteropServices.ComInterfaceType
System.Runtime.InteropServices.TypeLibTypeFlags




Multimobile Development: Building Applications for any Smartphone
Ad
BootFX
Reliable and powerful .NET application framework.
iOS, Android and Windows Phone Development Training and Consultancy
Hosted by RackSRV Communications
 
Multimobile Development: Building Applications for any Smartphone
Copyright © AMX Software Ltd 2008-2010. Portions copyright © Matthew Baxter-Reynolds 2001-2010. All rights reserved.
Contact Us - Terms of Use - Privacy Policy - 4.0.30129.1734