G
Guest
i'm attempting to interop from C# to a COM DLL, and have found some trouble
with a non-standard interface (at bottom of post - followed by my C# version).
typically COM methods return an HRESULT or just void. for some reason, this
one is returning a string (char *) or in other interfaces is returning a
struct.
i'm pretty familiar with interop for normal params and using IntPtr
marshalling to structures, but i'm not sure how this works in this case.
when calling GetName or GetType in this interface (via C#), i'm just getting
'null' or '0' for each call.
thanks for any help!
Kirk
-------------
interface IAudioComponent : public IUnknown
{
virtual const char *
GetName() PURE;
// Application should first call this method to determine the type
// of the component and after that query the appropriate interface.
virtual EAudioComponentType
GetType() PURE;
// This method is called after all the components are enumerated.
// It should perform the actual initialization and store pMgr for
// later use to access functionality provided by other plugins.
// If the component initialization fails, it should return false
// and the plugin manager will remove it from components list so
// it will not be available.
virtual bool
Init(IAudioPluginMgr *pMgr, IStatus **ppStatus = NULL) PURE;
virtual bool
Done() PURE;
};
[ComImport]
[Guid("0D7EA5C4-DAF9-4738-BB57-EEFDE39CFF8C")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IAudioComponent
{
StringBuilder GetName();
EAudioComponentType GetType();
bool Init(
[In, MarshalAs(UnmanagedType.Interface)] IAudioPluginMgr pMgr,
[Out, MarshalAs(UnmanagedType.Interface)] out IStatus ppStatus);
bool Done();
}
with a non-standard interface (at bottom of post - followed by my C# version).
typically COM methods return an HRESULT or just void. for some reason, this
one is returning a string (char *) or in other interfaces is returning a
struct.
i'm pretty familiar with interop for normal params and using IntPtr
marshalling to structures, but i'm not sure how this works in this case.
when calling GetName or GetType in this interface (via C#), i'm just getting
'null' or '0' for each call.
thanks for any help!
Kirk
-------------
interface IAudioComponent : public IUnknown
{
virtual const char *
GetName() PURE;
// Application should first call this method to determine the type
// of the component and after that query the appropriate interface.
virtual EAudioComponentType
GetType() PURE;
// This method is called after all the components are enumerated.
// It should perform the actual initialization and store pMgr for
// later use to access functionality provided by other plugins.
// If the component initialization fails, it should return false
// and the plugin manager will remove it from components list so
// it will not be available.
virtual bool
Init(IAudioPluginMgr *pMgr, IStatus **ppStatus = NULL) PURE;
virtual bool
Done() PURE;
};
[ComImport]
[Guid("0D7EA5C4-DAF9-4738-BB57-EEFDE39CFF8C")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IAudioComponent
{
StringBuilder GetName();
EAudioComponentType GetType();
bool Init(
[In, MarshalAs(UnmanagedType.Interface)] IAudioPluginMgr pMgr,
[Out, MarshalAs(UnmanagedType.Interface)] out IStatus ppStatus);
bool Done();
}