Temperatura Procesora i prędkość wentylatorka

0

Znalazłem w sieci taki kod:

unit Cputemp1;

interface

uses
  SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  Forms, Dialogs, StdCtrls, ExtCtrls;

type
  TForm1 = class(TForm)
    Label1: TLabel;
    Timer1: TTimer;
    Label2: TLabel;
    procedure FormCreate(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
  private
    { Private declarations }
  public
cnt: integer;
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.FormCreate(Sender: TObject);
begin
Label1.caption := 'T(MB)'+' °C';
Label2.caption := 'T(CPU)'+' °C';
end;

procedure TForm1.Timer1Timer(Sender: TObject);
  var
i: integer ;
mtm: integer;
ts: integer;
tm: integer;
ct: integer;
temp: real;
cond: boolean;
s: string;
s1: string;
begin
Timer1.Interval := 3000;
  {Read temperature}
   Port[$295] := $27;
   i := port [$296];
   str(i:2,s);
    Label1.caption := 'T(MB)  = '+s+' °C';
   { read cpu temp}
   mtm :=10;
   ts:=port[$e800] ;
   tm:=0;
   while (((ts and 1) = 1)and (tm < mtm)) do
   begin
   ts:=port[$e800];
   tm := tm+1;
   end;
   if (tm >= mtm) then Label2.caption := 'lm78 timeout1';
   tm:=0;
   if (((ts and $1e) <> 0)and (tm < mtm)) then
   begin
   port[$e800]:=ts;
   tm:=tm+1;
   end;
   if (tm >= mtm) then Label2.caption := 'lm78 timeout2';
   port[$e803]:=0;
   port[$e804]:=$93;
   ct:=port[$e802];
   ct:=(ct and $e0)or $c;
   port[$e802]:=ct;
   port[$e802]:=ct or $40;
   tm:=0;
   while (((port[$e800] and 1)= 1) and ( tm < mtm)) do tm:=tm+1;
   if (tm >= mtm) then Label2.caption := 'lm78 timeout3' ;
  temp:= port[$e805] ;
  ts := port[$e806] ;
   ts:= ts shr 7;
   ts := ts and 1;
     temp := temp +8;
   if (ts = 1) then temp:= temp + 0.5;
   str(temp:4:1,s1);
   Label2.caption := 'T(CPU)  = '+s1+' °C';
end;
end. 

Wszystko działa, oprócz tego, że w moim Turbo Delphi nie działa polecenie port :-[

Co zrobić, aby sprawdzić temperaturę procesora w Turbo Delphi i jak sprawdzić prędkość wentylatorka?

0

dlatego polecenie port ci nie działa bo na liscie Uses niemasz żadnego modułu który by zawierał w sobie takie polecenie, niemasz takze żadnej procedury lub funkcji port ani zadnej takiej zmiennej więc to niemoze działać:/

0

Turbo pascal posiadał zaimplementowaną przedefiniowaną tablicę Port[Word]. W delphi niestety nie ma tego. Jedyne co możesz zrobić to odwołać się do portów za pomocą API lub napisać wstawkę asm. I tu pewne ryzyko. System Windows skutecznie zabrania dostępu do niektórych portów (np. kontrolera HDD).

Pamiętaj w PMODE, stosujesz wstawki asm na własną odpowiedzialność. Dokumentacja SDK i Borlanda stanowczo odradza takie praktyki

function inport(const Port :Word) :Word; assembler;
asm
  mov DX, Port;
  in  AX, DX;
end;

procedure outport(const Port, Value :Word); assembler;
asm
  mov DX, Port;
  mov AX, Value;
  out DX, AX;
end;
0

A jak to zrobić za pomocą API? Mój windows skutecznie przeszkadza wstawcę asm w normalnym działaniu :/

1 użytkowników online, w tym zalogowanych: 0, gości: 1