Wouldn't this be a reliable solution:
var OldActiveLayer: Integer;
OldActiveLayer := ImageEnView1.LayersCurrent;
try
// if you only want to get the number of colors in your TImageEnView image
ImageEnView1.LayersCurrent := 0;
nc := ImageEnView1.Proc.CalcImageNumColors;
finally
ImageEnView1.LayersCurrent := OldActiveLayer;
end;