Topaz Filer: if you use e-mail for business, we can save you money and decrease your risk.
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...
 
Auto-following on Twitter
Ubuntu and XP on one “desktop”
 
    
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...
 
Outlook interop - stopping user properties appearing on Outlook message print
Seriously, why is “cut and paste” majorly newsworthy???
 
    
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...
 
Email Archiving and Email Filing - what’s the difference?
Web-based task/todo list management
 
 
System.IntPtr
System.Runtime.CompilerServices.MethodCodeType
System.Runtime.CompilerServices.MethodImplOptions
System.Runtime.InteropServices.ClassInterfaceType
System.Runtime.InteropServices.ComInterfaceType
System.Runtime.InteropServices.TypeLibTypeFlags




Ad
BootFX
Reliable and powerful .NET application framework.
Recession Busting Bespoke Software
Get through the recession by investing in bespoke software to decrease costs and create commercial opportunities.
Other DN247 Network Sites
.NET 247
SQL Server Wins
Old Skool Developer
 
Copyright © AMX Software Ltd 2008-2009. Portions copyright © Matthew Baxter-Reynolds 2001-2009. All rights reserved.
Contact Us - Terms of Use - Privacy Policy - .NET 247 is a member of the DN247 Network - 4.0.30129.1734