0
Answer

Convert an Object to IntPtr

Andrew

Andrew

15y
7.6k
1
Hello,

I am trying to convert an object to IntPtr so that I can pass it to the Win32 function GetWindowRect. I have used the code below, but my program just hangs

[StructLayout(LayoutKind.Sequential)]
public struct RECT
{
public int Left;
public int Top;
public int Right;
public int Bottom;
}

RECT rct;
IntPtr pt = Marshal.AllocHGlobal(Marshal.SizeOf(IE));
Marshal.StructureToPtr(IE, pt, true);
GetWindowRect(pt, out rct);

IE is of type object

Hope someone can help
Thanks