c# - Determine if window has close button (Or, why isn't GetTitleBarInfo working?) -
i'm trying determine if given window has close button using gettitlebarinfo function, recommended in this answer . when call function return value rgstate[5] - should indicate close button state - 0 , don't understand why. have idea i'm doing wrong here? alternatively, if 1 can suggest method information, helpful well. thanks! [dllimport("user32.dll", exactspelling = true, setlasterror = true)] internal static extern intptr getforegroundwindow(); [dllimport("user32.dll", setlasterror = true, charset = charset.auto)] [return: marshalas(unmanagedtype.bool)] internal static extern bool gettitlebarinfo(intptr hwnd, ref titlebarinfo pti); [structlayout(layoutkind.sequential)] internal struct titlebarinfo { public int cbsize; public rect rctitlebar; [marshalas(unmanagedtype.byvalarray, sizeconst = 6)] public int[] rgstate; } intptr handle = getforegroundwindow(); titlebarinfo titlebarinfo = new titlebarinfo(); titlebarinfo.cbsize = m...