Hvorfor beder den om .dfm fil.
Hvorfor beder nedenstående kilde om en DFM fil ?meningen er det skal være en selvstændig unit.
- Der kan addes til et andet project for at bruge gettemp():
====
unit MBMread;
interface
uses
Windows, StdCtrls, Controls, Classes, SysUtils;
type
TBusType = (btISA, btSMBus,btVIA686ABus, btDirectIO);
TSMBType = (smtSMBIntel, smtSMBAMD, smtSMBALi, smtSMBNForce, smtSMBSIS);
TSensorType = (stUnknown, stTemperature, stVoltage, stFan, stMhz, stPercentage);
TSharedIndex = record
iType : TSensorType; // type of sensor
Count : integer; // number of sensor for that type
end;
TSharedSensor = record
ssType : TSensorType; // type of sensor
ssName : array [0..11] of AnsiChar; // name of sensor
sspadding1: array [0..2] of Char; // padding of 3 byte
ssCurrent : Double; // current value
ssLow : Double; // lowest readout
ssHigh : Double; // highest readout
ssCount : LongInt; // total number of readout
sspadding2: array [0..3] of Char; // padding of 4 byte
ssTotal : Extended; // total amout of all readouts
sspadding3: array [0..5] of Char; // padding of 6 byte
ssAlarm1 : Double; // temp & fan: high alarm; voltage: % off;
ssAlarm2 : Double; // temp: low alarm
end;
TSharedInfo = record
siSMB_Base : Word; // SMBus base address
siSMB_Type : TBusType; // SMBus/Isa bus used to access chip
siSMB_Code : TSMBType; // SMBus sub type, Intel, AMD or ALi
siSMB_Addr : Byte; // Address of sensor chip on SMBus
siSMB_Name : array [0..40] of AnsiChar; // Nice name for SMBus
siISA_Base : Word; // ISA base address of sensor chip on ISA
siChipType : Integer; // Chip nr, connects with Chipinfo.ini
siVoltageSubType : Byte; // Subvoltage option selected
end;
TSharedData = record
sdVersion : Double; // version number (example: 51090)
sdIndex : array [0..9] of TSharedIndex; // Sensor index
sdSensor : array [0..99] of TSharedSensor; // sensor info
sdInfo : TSharedInfo; // misc. info
sdStart : array [0..40] of AnsiChar; // start time
sdCurrent : array [0..40] of AnsiChar; // current time
sdPath : array [0..255] of AnsiChar; // MBM path
end;
PSharedData = ^TSharedData;
var
SharedIndex : TSharedIndex;
SharedSensor : TSharedSensor;
SharedInfo : TSharedInfo;
SharedData : PSharedData;
implementation
{$R *.DFM}
function gettemp(nr: integer):double;
var myHandle : Integer;
begin
myHandle := OpenFileMapping(FILE_MAP_READ, False, '$M$B$M$5$S$D$');
if myHandle > 0 then begin
SharedData := MapViewOfFile(myHandle, FILE_MAP_READ, 0, 0, 0);
with SharedData^ do gettemp:=sdSensor[0].ssCurrent;
end
else
gettemp:=0;
end;
end.
