unit Main;
interface
uses
Windows, SysUtils, Classes, Forms,
Controls, StdCtrls;
type
TMyRecord =
Packed Record
Unknown :
Array[0..5]
of SmallInt;
//unbekanntes Tag
NumTemps : SmallInt;
//Anzahl der Temperaturen
NumFans : SmallInt;
//Anzahl der Lüfter
NumVolts : SmallInt;
//Anzahl der Spannungen
Temps :
Array[0..63]
of Integer;
//Werte der Temperaturen
Fans :
Array[0..63]
of Integer;
//Drehzahl der Lüfter
Volts :
Array[0..63]
of Integer;
//Werte der Spannungen
end;
TForm1 =
class(TForm)
Memo1: TMemo;
Button2: TButton;
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
const
mbuff = 1000;
var
Form1: TForm1;
buffer :
array [0..mbuff]
of integer;
myrecord : tmyrecord
absolute buffer;
implementation
{$R *.dfm}
procedure TForm1.Button2Click(Sender: TObject);
var
hSFMemory: HWND;
SfAreaPtr: Pointer ;
MyResultRecord: TMyRecord;
i: Integer;
begin
fillchar(buffer,1000,0);
hSFMemory := 0;
SfAreaPtr :=
nil;
try
hSFMemory := OpenFileMapping(FILE_MAP_READ, False, '
SFSharedMemory_ALM');
if HSFMemory <> 0
then begin
SfAreaPtr := MapViewOfFile(hSFMemory, FILE_MAP_READ, 0, 0, 0);
CopyMemory(Addr(MyResultRecord),SfAreaPtr,sizeof(MyResultRecord));
memo1.Text:= memo1.Text+'
Number Of Temps:'+inttostr(MyResultRecord.NumTemps)+#13+#10;
memo1.Text:= memo1.Text+'
Number Of Fans:'+inttostr(MyResultRecord.NumFans)+#13+#10;
memo1.Text:= memo1.Text+'
Number Of Volts:'+inttostr(MyResultRecord.NumVolts)+#13+#10;
For i:= 0
to MyResultRecord.NumFans -1
do begin
MyResultRecord.Fans[i]:= MyResultRecord.Fans[i]
div 100;
memo1.Text:= memo1.Text+'
Fan'+inttostr(i)+'
:'+inttostr(MyResultRecord.Fans[i])+#13+#10;
end;
For i:= 0
to MyResultRecord.numTemps -1
do begin
MyResultRecord.Temps[i]:= MyResultRecord.Temps[i]
div 100;
memo1.Text:= memo1.Text+'
Temp'+inttostr(i)+'
:'+inttostr(MyResultRecord.Temps[i])+#13+#10;
end;
For i:= 0
to MyResultRecord.NumVolts -1
do begin
MyResultRecord.Volts[i]:= MyResultRecord.Volts[i]
div 100;
memo1.Text:= memo1.Text+'
Fan'+inttostr(i)+'
:'+inttostr(MyResultRecord.Volts[i])+#13+#10;
end
end;
finally
UnmapViewOfFile(SfAreaPtr);
CloseHandle(hSFMemory);
end;
end;
end.