Altro Incompatible types: 'string' and 'Double' (Delphi XE)

mrcamarium

Utente Bronze
7 Gennaio 2022
68
16
1
26
Ultima modifica:
Sto cercando di riunire delle informazioni in un Tmemo:
Codice:
function GetCPUSpeed: Double;
const
  DelayTime = 500;
var
  TimerHi, TimerLo: DWORD;
  PriorityClass, Priority: Integer;
begin
  PriorityClass := GetPriorityClass(GetCurrentProcess);
  Priority      := GetThreadPriority(GetCurrentThread);
  SetPriorityClass(GetCurrentProcess, REALTIME_PRIORITY_CLASS);
  SetThreadPriority(GetCurrentThread, THREAD_PRIORITY_TIME_CRITICAL);
  Sleep(10);
  asm
    dw 310Fh
    mov TimerLo, eax
    mov TimerHi, edx
  end;
  Sleep(DelayTime);
  asm
    dw 310Fh
    sub eax, TimerLo
    sbb edx, TimerHi
    mov TimerLo, eax
    mov TimerHi, edx
  end;
  SetThreadPriority(GetCurrentThread, Priority);
  SetPriorityClass(GetCurrentProcess, PriorityClass);
  Result := TimerLo / (1000 * DelayTime);
end;


procedure TForm1.Button1Click(Sender: TObject);
begin
  ShowMessage(Format('Your CPU speed: %f MHz', [GetCPUSpeed]));
  Label1.caption := GetCPUSpeed;
  Memo1.Lines := GetCPUSpeed;
end;
Riesco a ottenere i dati in un ShowMessage ma non riesco a usare ne un Label ne il Memo perchè ho bisogno di convertire i dati in stringa. Mi da questo errore:
[DCC Error] speed_cpu.pas(62): E2010 Incompatible types: 'string' and 'Double'
Ho fatto le opportune modifiche:
Codice:
procedure TForm1.FormCreate(Sender: TObject);
var
  ids: TidIpWatch;
  Speed: Double;
begin
 ids := TidIpWatch.Create;
 Speed := GetCPUSpeed;
 Memo1.Text := 'IP:' + (ids.LocalIP);
 Memo1.Text := (Tipo_cpu);
 Memo1.Text := Format('%f', [Speed]);
 ids.Free;
 end;
 

mrcamarium

Utente Bronze
7 Gennaio 2022
68
16
1
26
Fatto:
Codice:
procedure TForm1.FormCreate(Sender: TObject);
var
  ids: TidIpWatch;
  Speed: Double;
  myStringList: TStringList;
begin
 ids := TidIpWatch.Create;
 Speed := GetCPUSpeed;
 ids.Free;
 myStringList:=TStringList.Create;
 myStringList.Add('IP:' + (ids.LocalIP));
 myStringList.Add('CPU: ' + (Tipo_cpu) + ' ' + Format('%f', [Speed]));
 myStringList.Add((IsSoundCardInstalled));
 myStringList.Add('etc.');
 Memo1.Lines.Assign(myStringList);
 myStringList.Free;
 end;