箭牌与华雕卫浴哪个好:用Visual Basic怎样得到CPU以及硬盘的温度?

来源:百度文库 编辑:杭州交通信息网 时间:2024/05/06 11:59:28
用什么函数返回CPU的温度?
用什么函数返回硬盘的温度?
最好把函数声明也发上来……………………
一楼的看不懂,一点注释也没有…………
一楼的看不懂,一点注释也没有…………
一楼的看不懂,一点注释也没有…………
一楼的看不懂,一点注释也没有…………

unit Monitor;

interface

uses
windows, SMB, winbond, Menus, ToolWin, Graphics, ImgList, Controls, StdCtrls, CheckLst, Forms, MyUtils, Classes, PCI,
SysUtils, ComCtrls, ExtCtrls,UnitPortTalk;

type
TForm1 = class(TForm)
Timer2: TTimer;
PopupMenu1: TPopupMenu;
Setting1: TMenuItem;
Default1: TMenuItem;
N1: TMenuItem;
Exit1: TMenuItem;
Silence1: TMenuItem;
ImageList1: TImageList;
Panel3: TPanel;
Panel1: TPanel;
Panel4: TPanel;
Panel2: TPanel;
PageControl1: TPageControl;
TabSheet1: TTabSheet;
GroupBox5: TGroupBox;
Image2: TImage;
Label1: TLabel;
lblVID: TLabel;
lblVIN: TLabel;
Label2: TLabel;
Label3: TLabel;
lblDID: TLabel;
lblDIN: TLabel;
Label4: TLabel;
Label8: TLabel;
lblRev: TLabel;
lblBus: TLabel;
Label5: TLabel;
Label6: TLabel;
lblDev: TLabel;
lblFun: TLabel;
Label9: TLabel;
Label7: TLabel;
lblSMBA: TLabel;
GroupBox1: TGroupBox;
Label12: TLabel;
lblCVIN: TLabel;
lblCDIN: TLabel;
Label14: TLabel;
Label10: TLabel;
lblCVID: TLabel;
lclCDID: TLabel;
Label13: TLabel;
Image4: TImage;
GroupBox6: TGroupBox;
Image1: TImage;
Cklb1: TCheckListBox;
TabSheet4: TTabSheet;
GroupBox2: TGroupBox;
Image5: TImage;
lblf1: TLabel;
lblf2: TLabel;
lblf3: TLabel;
Label28: TLabel;
Label21: TLabel;
Label20: TLabel;
GroupBox3: TGroupBox;
Image3: TImage;
Label16: TLabel;
lbltCPU: TLabel;
lblt02: TLabel;
Label17: TLabel;
Label23: TLabel;
lblt03: TLabel;
lblt04: TLabel;
Label27: TLabel;
lblt05: TLabel;
Label30: TLabel;
Image7: TImage;
Image6: TImage;
GroupBox4: TGroupBox;
Label15: TLabel;
lblT1: TLabel;
lblT2: TLabel;
Label18: TLabel;
Label19: TLabel;
lblT3: TLabel;
lblT4: TLabel;
Label22: TLabel;
Label26: TLabel;
lblT6: TLabel;
lblT5: TLabel;
Label25: TLabel;
lblT7: TLabel;
Label24: TLabel;
Image8: TImage;
lblVBAT: TLabel;
Label29: TLabel;
lbl5VSB: TLabel;
Label31: TLabel;
TabSheet3: TTabSheet;
DebugPrint: TMemo;
Image9: TImage;
Main1: TMenuItem;
Monitor1: TMenuItem;
ToolBar1: TToolBar;
procedure FormCreate(Sender: TObject);
procedure Timer2Timer(Sender: TObject);
procedure Action1Execute(Sender: TObject);
Procedure Display_PCI_Info;
Procedure Display_SMBUS_Info;
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
private
{ Private declarations }

public
{ Public declarations }
end;

var
Form1: TForm1;
PCI_Structure1: PCI_Info;
CHIP_Structure: Chip_Info;
Valori: Packet_Data;
SMB_AF: string;
SMB_CF: integer;
MutexSMB: integer;
MutexISA: integer;

implementation

{$R *.DFM}

function Get_Hex(Data: cardinal; nbyte: smallint): string;
begin
Result := rStr('00000000' + Format('%x', [Data]), nbyte);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
Application.HintColor:=$009DCEFF;
Application.HintPause:=300;
Application.HintHidePause:=5000;
DebugPrint.Lines.add('Load form ...');
MutexISA := CreateMutex(nil, false, 'Access_ISABUS.HTP.Method');
MutexSMB := CreateMutex(nil, false, 'Access_SMBUS.HTP.Method');
DebugPrint.Lines.add('Scan PCI ...');
PCI_Structure1 := Scan_PCI;
if PCI_Structure1.SMB_Address <> 0 then begin
DebugPrint.Lines.add('Scan PCI ended ...');
Display_PCI_Info;
DebugPrint.Lines.add('Read SMBUS ...');
if PCI_Structure1.SMB_Address=$e800 then
PCI_Structure1.SMB_Address:=$290;
CHIP_Structure := Winbond_Info(PCI_Structure1.SMB_Address, $2D);
Display_SMBUS_Info;
end
else begin
DebugPrint.Lines.add('PCI chip not found or unknow !!!');
DebugPrint.Lines.add('STOP program !!!');
end;
end;

Procedure TForm1.Display_SMBUS_Info;
begin
WaitforSingleObject(MutexSMB, INFINITE);
WaitforSingleObject(MutexISA, INFINITE);
Cklb1.Checked[2] := True;
lblCVID.Caption := '0x' + Format('%x', [CHIP_Structure.Vendor_ID]);
lblCVIN.Caption := CHIP_Structure.Vendor_Name;
lclCDID.Caption := '0x' + Format('%x', [CHIP_Structure.Device_ID]);
lblCDIN.Caption := CHIP_Structure.Device_Name;
Cklb1.Checked[3] := True;
ReleaseMutex(MutexISA);
ReleaseMutex(MutexSMB);
Timer2.Enabled := True;
DebugPrint.Lines.add('Start program ... ');
PageControl1.ActivePage:=TabSheet1;
end;

Procedure TForm1.Display_PCI_Info;
begin
Cklb1.Checked[0] := True;
lblVID.Caption := '0x' + Get_Hex(PCI_Structure1.Vendor_ID, 4);
lblDID.Caption := '0x' + Get_Hex(PCI_Structure1.Device_ID, 4);
lblRev.Caption := '0x' + Get_Hex(PCI_Structure1.Rev, 2);
lblBus.Caption := '0x' + Get_Hex(PCI_Structure1.Bus, 2);
lblDev.Caption := '0x' + Get_Hex(PCI_Structure1.Dev, 2);
lblFun.Caption := '0x' + Get_Hex(PCI_Structure1.Fun, 2);
lblSMBA.Caption := '0x' + Get_Hex(PCI_Structure1.SMB_Address, 4);
lblVIN.Caption := PCI_Structure1.Vendor_Name;
lblDIN.Caption := PCI_Structure1.Device_Name;
Cklb1.Checked[1] := True;
end;

procedure TForm1.Timer2Timer(Sender: TObject);
var
s: string;

begin
WaitforSingleObject(MutexISA, INFINITE);
WaitforSingleObject(MutexSMB, INFINITE);
Valori := Winbond_Chip(PCI_Structure1.SMB_Address,0);
ReleaseMutex(MutexISA);
ReleaseMutex(MutexSMB);
lblT1.Caption := Valori.IN0;
lblT2.Caption := Valori.IN1;
lblT3.Caption := Valori.IN2;
lblT4.Caption := Valori.IN3;
lblT5.Caption := Valori.IN4;
lblT6.Caption := Valori.IN5;
lblT7.Caption := Valori.IN6;
lblVBAT.Caption := Valori.IN7;
lbl5VSB.Caption := Valori.IN8;
lbltCPU.Caption := Valori.TEMP1value
lblt02.Caption := Valori.TEMP2value
lblt03.Caption := Valori.TEMP3value
lblt04.Caption := Valori.TEMP4value
lblt05.Caption := Valori.TEMP5value
lblf1.Caption := Valori.FAN1rpm;
lblf2.Caption := Valori.FAN2rpm;
lblf3.Caption := Valori.FAN3rpm;
PageControl1.Enabled := True;
Cklb1.Checked[4] := True;
s := LStr(Valori.TEMP1value, length(Valori.TEMP1value) - 4);
end;

procedure TForm1.Action1Execute(Sender: TObject);
begin
Form1.Close;
end;

procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
Timer2.Enabled:=false;
ClosePortTalk;
CloseHandle(MutexISA);
CloseHandle(MutexSMB);
end;

end.

521