If you work with graphics, it's sometimes useful to know what color depth your user's video card is set at. I created this function to do that for me, which returns a string result. You can change the function to return an Int64 (Delphi 4/5) or Comp (Delphi 3) type instead if you need to work with the numbers. uses Math;
functionGetColorDepth: string; { func to get the current color depth of the video card. } var tmpStr: string; x: integer; DeviceContents: HDC; ColorDepth: Extended; begin DeviceContents := GetDC(0); x := GetDeviceCaps(DeviceContents, BitsPixel) * GetDeviceCaps(DeviceContents, Planes); ColorDepth := Power(2, x); ReleaseDC(0, DeviceContents); tmpstr := Format('%d Colors ', [Trunc(ColorDepth)]); case x of 1: tmpstr := tmpstr + 'MonoChrome'; 16: tmpstr := tmpstr + 'HiColor (16 Bit)'; 24: tmpstr := tmpstr + 'TrueColor (24 Bit)'; 32: tmpstr := tmpstr + 'TrueColor (32 Bit)'; 64: tmpstr := tmpstr + 'UltraColor (64 Bit)'; end; Result := tmpstr; end;