gdi32: Move the query info code to a separate function.