Sources
Delphi Russian Knowledge Base
DRKB - это самая большая и удобная в использовании база знаний по Дельфи в рунете, составленная Виталием Невзоровым

Как узнать количество цветов в системной палитре?

01.01.2007
function GetNumColors: LongInt;
var
  BPP
: Integer;
  DC
: HDC;
begin
  DC
:= CreateDC('DISPLAY', nil, nil, nil);
 
if DC <> 0 then
   
begin
     
try
        BPP
:= GetDeviceCaps(DC, BITPIXEL) * GetDeviceCaps(DC, PLANES);
     
finally
       
DeleteDC(DC);
     
end;
     
case BPP of
       
1: Result := 2;
       
4: Result := 16;
       
8: Result := 256;
       
15: Result := 32768;
       
16: Result := 65536;
       
24: Result := 16777216;
     
end;
   
end
 
else
   
Result := 0;
end;