I am passing an IntPtr
to a function SendMessageTimeout
as below.
SendMessageTimeout
belongs to user32.dll.
I dont know how this DLL allcoates memory to the IntPtr
passed as reference, i.e result
.
How to release memory of IntPtr
passed to this function?
[DllImport("user32")]
public static extern int SendMessageTimeout(
int hwnd, int msg, int wparam, int lparam,
int fuFlags, int uTimeout, IntPtr lpdwResult);
if (handle > 0 && GetWindowText(handle, Buff, nChars) > 0)
{
this.log("GetForegroundWindow : " +Buff.ToString());
foreach (string str in this.titleList)
{
if (Buff.ToString().ToLower().Contains(str.ToLower()))
{
IntPtr result = IntPtr.Zero;
if (SendMessageTimeout(handle, 0x0010, 0, 0, 0x0002, 2000, result) != 0)
DestroyWindow(handle);
killed = true;
break;
}
}
}