I am calling an unmanaged funtion [1] like this [2] and it works but I am
worried that I should be freeing memory allocated to the IntPtr - should I,
and if so, how?
[1]
DWORD GetID(PBYTE* ppbID, LPDWORD pcbID);
[2]
[DllImport(dllName)]
private static extern uint GetID([Out] out IntPtr ppbID, [Out] out int
pcbID);
public static byte[] GetID()
{
IntPtr pID;
int length;
GetID(out pID, out length);
// Create array
byte[] id = new byte[length];
// Copy contents
Marshal.Copy(pID, id, 0, id.Length);
return id;
}
Mattias Sj?gren - 27 Jan 2005 09:00 GMT
>I am calling an unmanaged funtion [1] like this [2] and it works but I am
>worried that I should be freeing memory allocated to the IntPtr - should I,
>and if so, how?
The documentation of the GetID function will have to tell you that.
Mattias

Signature
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.