DllImport and using Win32 API GetParent return no value

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...
 
G

Guest

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top