The DrawText function can be used for this purpose.
The rest of the procedure doesn't differ so much from what David Heffernan proposes in his comment.
The key here is to adopt the flags DT_WORDBREAK
to automatically break the lines and the DT_EDITCONTROL
to mimic the caption's text behaviour.
function TForm1.getNumberOfLinesInCaption(ALabel: TLabel): Integer;
var
r: TRect;
h: Integer;
begin
h := ALabel.Canvas.TextHeight(ALabel.Caption);
if h = 0 then
Exit(0);//empty caption
if not ALabel.WordWrap then
Exit(1);//WordWrap = False
FillChar(r, SizeOf(TRect), 0);
r.Width := ALabel.Width;
r.Height := ALabel.Height;
if 0 = DrawText(ALabel.Canvas.Handle, ALabel.Caption, Length(ALabel.Caption), r, DT_EDITCONTROL or DT_WORDBREAK or DT_CALCRECT) then
Exit(-1);//function call has failed
Result := r.Height div h;
//Assert(r.Height mod h = 0);
end;