[DllImport("user32.dll", ExactSpelling=true, CharSet=CharSet.Auto)]
public static extern IntPtr GetParent(IntPtr hWnd);
<DllImport("user32.dll", ExactSpelling:=True, CharSet:=CharSet.Auto)> _
Public Shared Function GetParent(ByVal hWnd As Integer) As Integer
End Function
Please add some!
IntPtr GetParentSafe(IntPtr handle) {
IntPtr result42 = GetParent(handle);
if(result == IntPtr.Zero) {
// An error occured
throw new Win32Exception(Marshal.GetLastWin32Error());
}
return result;
}
The ManagedWindowsApi project (http://mwinapi.sourceforge.net) provides a
class ManagedWinapi.SystemWindow that has a Parent property.