Marshal Class In API Call

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
}
 
N

Nicholas Paldino [.NET/C# MVP]

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);
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top