Marshal Class In API Call

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have an API call function which return a pointer of C++ class object. I need the m_pData and m_lSize in the object

CReturnClass *APIFunction(void)

1. Could I directly use this API function in VS.NET by using DLLImport Declare? I don't want to wrap this dll in C++
2. If yes, How could I Decalare the class [CReturnClass] in .NET. How could I marshal it

Thanks


class CReturnClass

public
CReturnClass (LPBYTE pSource, int nCount, bool bIsKey = false, bool bCompressed = true, bool bAutoDelete = true)
virtual ~CReturnClass(void)

bool IsCompressed() cons
{ return m_bIsCompressed;
bool IsKeyFrame() cons
{ return m_bIsKey;
LONG GetSize() cons
{ return m_lSize;
const LPBYTE GetBuffer() cons
{ return m_pData;
void Close(
{ delete this;

protected
CReturnClass(void)

private
bool m_bIsCompressed
bool m_bIsKey
bool m_bAutoDelete
LPBYTE m_pData
LONG m_lSize
}
 
Qindong,

You will not be able to use this class in .NET. You will have to either
expose it as a COM component, or use the Managed Extensions for C++ to
create a managed wrapper for this class.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Qindong Z. said:
I have an API call function which return a pointer of C++ class object. I
need the m_pData and m_lSize in the object.
CReturnClass *APIFunction(void);

1. Could I directly use this API function in VS.NET by using DLLImport
Declare? I don't want to wrap this dll in C++.
2. If yes, How could I Decalare the class [CReturnClass] in .NET. How could I marshal it?

Thanks.



class CReturnClass
{
public:
CReturnClass (LPBYTE pSource, int nCount, bool bIsKey = false, bool
bCompressed = true, bool bAutoDelete = true);
 
Back
Top