DllImport and using Win32 API GetParent return no value

  • Thread starter Thread starter Sanghoon Lee
  • Start date Start date
S

Sanghoon Lee

I wrote tiny sample of smart client using Win32 API and get parent IE's
handle as follow

[DllImport("User32.dll")]
public static extern IntPtr GetParent(IntPtr hWnd);


IntPtr cHandle = this.Handle; // this is smart client
IntPtr pHandle = GetParent(cHandle); // oHandle will be IE's handler

After getting pHandle, I'll get some properties of parent browser.
However, GetParent method return only zero not proper handler.

I want to know how to get the parent browser handler.

Thanks in advance...
 
Hi Sanghoon,
check to see if there was an error getting the parent i.e.

[DllImport("User32.dll", SetLastError=true)]
public static extern IntPtr GetParent(IntPtr hWnd);

Then use Marshal.GetLastWin32Error() to see if there was an error code
created when you called the GetParent method, that may give you more
information. It is valid that the value coming back from this function is
zero in some cases.

Mark.
 
Back
Top