In general it's not possible to determine the DPI of a screen because some screens don't have a fixed size, for example projectors. You could try ask the user to input in a display size manually.
...