Q:

What's the best way do determine if an HWND represents a top-level window? 

Is it to check for the WS_CHILD bit:
    LONG style = GetWindowLong(hwnd, GWL_STYLE);
    int isTopLevel = !( style & WS_CHILD);

Or is there a better way? 
Assume: Straight C calling only existing Windows API code. 

A:

Way #1: Test hWnd==GetAncestor(hWnd,GA_ROOT)
Way #2: Use IsTopLevelWindow (user32 Win7, undocumented)

