Groups | Blog | Home
all groups > dotnet interop > october 2003 >

dotnet interop : Array


XingZheng
10/31/2003 11:43:40 AM
Hi
I use pInvoke to call Dll.
How to delete buffer which is allocated in visual c++.

In Visual C ++
public void GetArray(BYTE* &buffer, UINT* length)
{
buffer = new BYTE[10]; //How to delete buffer in C#
......
}

In C#
public void GetArray(out IntPtr lpBuf, out int length);

Thanks.

Ying-Shen Yu
11/3/2003 1:36:10 AM
Hi,
As I know, You can't free the memory allocated in your unmanaged code.
You need provide another unmanaged function for deleting, or use
the Marshal.AllocateHGlobal to allocate the memory on .NET Unmanaged heap,
pass it into your unmanaged code and free it using Marshal.FreeHGlobal
method after using it.
HTH.


--
Ying-Shen Yu
Meet a Problem in .NET? try google MSFT + "keywords"
"XingZheng" <xingzheng23@netscape.net> дÈëÓʼþ
news:O8eBwm2nDHA.2364@TK2MSFTNGP11.phx.gbl...
[quoted text, click to view]

AddThis Social Bookmark Button