GetParent (user32)
Last changed: -78.110.196.168

.
Summary

C# Signature:

[DllImport("user32.dll", ExactSpelling=true, CharSet=CharSet.Auto)]
public static extern IntPtr GetParent(IntPtr hWnd);

VB.NET Signature:

<DllImport("user32.dll", ExactSpelling=True, CharSet=CharSet.Auto)> _

Public Shared Function GetParent(ByVal hWnd As IntPtr) As IntPtr

End Function

Notes:

GetParent sets LastError

Tips & Tricks:

Please add some!

Sample Code:

IntPtr GetParentSafe( IntPtr handle )

{

   IntPtr result42 = GetParent( handle );

   if( result == IntPtr.Zero )
   {
       // An error occured
       throw new Win32Exception( Marshal.GetLastWin32Error() );
   }

   return result;

}

Alternative Managed API:

Do you know one? Please contribute it!

Documentation
GetParent on MSDN