下面这段代码可以试试!<br> type<br> TBus = (ISA, SMBus, VIA686ABus, DirectIO);<br> TSMB = (SMBIntel, SMBAMD, SMBALi);<br> type<br> TSharedData = Record<br> STemperature : array [1..10] of Integer; <br> SVoltage : array [1..10] of Real; <br> SFan : array [1..10] of Integer; <br> SMHZ : Integer; <br> SNrCPU : Byte; <br> SCPUUsage : array [1..4] of Real; <br> end;<br> TSharedInfo = Record<br> SMBM_Version : array [0..10] of Char; <br> SSMB_Base : Word; <br> SSMB_Type : TBus; <br> SSMB_Code : TSMB; <br> SSMB_Addr : Byte; <br> SSMB_Name : array [0..40] of Char; <br> SISA_Base : Word; <br> SChipType : Integer; <br> SVoltageSubType : Byte; <br> end;<br> TSharedHL = Record <br> STempC : array [1..10] of LongInt; <br> STempA : array [1..10] of Extended; <br> STempL : array [1..10] of Real; <br> STempH : array [1..10] of Real; <br> SVoltC : array [1..10] of LongInt; <br> SVoltA : array [1..10] of Extended; <br> SVoltL : array [1..10] of Real; <br> SVoltH : array [1..10] of Real; <br> SFanC : array [1..10] of LongInt; <br> SFanA : array [1..10] of Extended; <br> SFanL : array [1..10] of Real; <br> SFanH : array [1..10] of Real; <br> SStart : array [0..40] of Char; <br> SCurrent : array [0..40] of Char; <br> SCPUC : array [1..4] of LongInt; <br> SCPUA : array [1..4] of Extended; <br> SCPUL : array [1..4] of Real; <br> SCPUH : array [1..4] of Real; <br> end;<br> TSharedName = Record<br> STempName : array [1..10] of array [0..10] of Char; <br> SVoltName : array [1..10] of array [0..10] of Char; <br> SFanName : array [1..10] of array [0..10] of Char; <br> SCPUName : array [0..10] of Char; <br> SCPUUSageName : array [0..10] of Char; <br> end;<br> PSharedData = ^TSharedData;<br> PSharedInfo = ^TSharedInfo;<br> PSharedHL = ^TSharedHL;<br> PSharedName = ^TSharedName;<br>var<br> CPUMhz : Integer;<br> CPUNr : Byte;<br> Temperature : array [1..10] of Integer<br> Voltage : array [1..10] of Real;<br> Fan : array [1..10] of Integer;<br> CPU : array [1..4] of Real;<br> UsedBus : TBus;<br> IsaBase : Word;<br> SMB_BASE : Word;<br> SMBusType : TSMB;<br> SMB_NAME : String;<br> SMBChipAddress : Byte;<br> ChipType : Integer;<br> TempL : array[1..10] of Real;<br> TempH : array[1..10] of Real;<br> TempA : array[1..10] of Extended;<br> TempC : array[1..10] of LongInt;<br> VoltL : array[1..10] of Real;<br> VoltH : array[1..10] of Real;<br> VoltA : array[1..10] of Extended;<br> VoltC : array[1..10] of LongInt;<br> FanL : array[1..10] of Real;<br> FanH : array[1..10] of Real;<br> FanA : array[1..10] of Extended;<br> FanC : array[1..10] of LongInt;<br> StartingTimeLog : String;<br> CurrentTimeLog : String;<br> CPUL : array[1..4] of Real;<br> CPUH : array[1..4] of Real;<br> CPUA : array[1..4] of Extended;<br> CPUC : array[1..4] of LongInt; <br> TempName : array[1..10] of String;<br> VoltName : array[1..10] of String;<br> FanName : array[1..10] of String;<br> CPUName : String;<br> CPUUsageName : String;<br>function ReadSharedData : Boolean;<br>function ReadSharedInfo : Boolean;<br>function ReadSharedHL : Boolean;<br>function ReadSharedName : Boolean;<br>implementation<br>function ReadSharedData : Boolean;<br>var<br> PSH : PSharedData;<br> hSData : Integer;<br> X : Integer;<br>begin<br> Result:=False;<br> hSData:=OpenFileMapping(FILE_MAP_READ, False, '$M$B$M$5$D$');<br> if hSData=0 then Exit;<br> PSH:=MapViewOfFile(hSData, FILE_MAP_READ, 0, 0, 0);<br> if PSH=Nil then<br> begin<br> CloseHandle(hSData);<br> Exit;<br> end;<br> with PSH^ do<br> begin<br> for X:=1 to 10 do Temperature[X]:=STemperature[X];<br> for X:=1 to 10 do Voltage[X]:=SVoltage[X];<br> for X:=1 to 10 do Fan[X]:=SFan[X];<br> CPUMHZ:=SMHZ;<br> CPUNr:=SNrCPU;<br> for X:=1 to 4 do CPU[X]:=SCPU[X];<br> end;<br> UnMapViewOfFile(PSH);<br> CloseHandle(hSData);<br> Result:=True;<br>end;<br>function ReadSharedInfo : Boolean;<br>var<br> PSH : PSharedInfo;<br> hSInfo : Integer;<br>begin<br> Result:=False;<br> hSInfo:=OpenFileMapping(FILE_MAP_READ, False, '$M$B$M$5$I$');<br> if hSInfo=0 then Exit;<br> PSH:=MapViewOfFile(hSInfo, FILE_MAP_READ, 0, 0, 0);<br> if PSH=Nil then<br> begin<br> CloseHandle(hSInfo);<br> Exit;<br> end;<br> with PSH^ do<br> begin<br> SMB_Base:=SSMB_Base;<br> UsedBus:=SSMB_Type;<br> SmbusType:=SSMB_Code;<br> SMBChipAddress:=SSMB_Addr;<br> SMB_Name:=StrPas(SSMB_Name);<br> ISABase:=SISA_Base;<br> ChipType:=SChipType;<br> VoltageSubType:=SVoltageSubType;<br> end;<br> UnMapViewOfFile(PSH);<br> CloseHandle(hSInfo);<br> Result:=True;<br>end;<br>function ReadSharedHL : Boolean;<br>var<br> PSH : PSharedHL;<br> hSHL : Integer;<br> X : Integer;<br>begin<br> Result:=False;<br> hSHL:=OpenFileMapping(FILE_MAP_READ, False, '$M$B$M$5$H$');<br> if hSHL =0 then Exit;<br> PSH:=MapViewOfFile(hSHL, FILE_MAP_READ, 0, 0, 0);<br> if PSH=Nil then<br> begin<br> CloseHandle(hSHL);<br> Exit;<br> end;<br> with PSH^ do<br> begin<br> for X:=1 to 10 do<br> begin<br> TempL[X]:=STempL[X];<br> TempH[X]:=STempH[X];<br> TempA[X]:=STempA[X];<br> TempC[X]:=STempC[X];<br> end;<br> for X:=1 to 10 do<br> begin<br> VoltL[X]:=SVoltL[X];<br> VoltH[X]:=SVoltH[X];<br> VoltA[X]:=SVoltA[X];<br> VoltC[X]:=SVoltC[X];<br> end;<br> for X:=1 to 10 do<br> begin<br> FanL[X]:=SFanL[X];<br> FanH[X]:=SFanH[X];<br> FanA[X]:=SFanA[X];<br> FanC[X]:=SFanC[X];<br> end;<br> StartingTimeLog:=StrPas(SStart);<br> CurrentTimeLog:=StrPas(SCurrent);<br> for X:=1 to 4 do<br> begin<br> CPUL[X]:=SCPUL[X];<br> CPUH[X]:=SCPUH[X];<br> CPUA[X]:=SCPUA[X];<br> CPUC[X]:=SCPUC[X];<br> end;<br> end;<br> UnMapViewOfFile(PSH);<br> CloseHandle(hSHL);<br> Result:=True;<br>end;<br>function ReadSharedName : Boolean;<br>var<br> PSH : PSharedName;<br> hSData : Integer;<br> X : Integer;<br>begin<br> Result:=False;<br> hSData:=OpenFileMapping(FILE_MAP_READ, False, '$M$B$M$5$N$');<br> if hSData=0 then Exit;<br> PSH:=MapViewOfFile(hSData, FILE_MAP_READ, 0, 0, 0);<br> if PSH=Nil then<br> begin<br> CloseHandle(hSData);<br> Exit;<br> end;<br> with PSH^ do<br> begin<br> for X:=1 to 10 do TempName[X]:=StrPas(STempName[X])<br> for X:=1 to 10 do VoltName[X]:=StrPas(VoltName[X])<br> for X:=1 to 10 do FanName[X]:=StrPas(FanName[X])<br> CPUName:=StrPas(SCPUName);<br> CPUUsageName:=StrPas(SCPUName);<br> end;<br> UnMapViewOfFile(PSH);<br> CloseHandle(hSData);<br> Result:=True;<br>end;<br>