I have some C# code that is used in a win32 application via ComInterop, it is embedded as an OleControl.
In my win32 app I send through the handle to the containing window for the C# control (win32 app code):
oControl:ShowPreview(5, 3, INT(_CAST, SELF:Handle(0)))
In my C# code I pick this up and store it in an IntPtr (C# code):
private IntPtr _parentWindowPtr;
public int ShowPreview(int someVar1, int someVar2, int parent)
{
...
_parentWindowPtr = new IntPtr(parent);
...
}
Should I be releasing or destroying the IntPtr in the C# code?