⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cmostool.pas

📁 MiniHex 1.1 源程序说明 “MiniHex11SrcSource”目录中的所有文件是MiniHex 1.1的主程序; “MiniHex11SrcControls”目录中的是该软件
💻 PAS
字号:
{**********************************************************}
{                                                          }
{  Unit CMOSTool 1.0                                       }
{                                                          }
{  Function: Read and Write CMOS Data.                     }
{            for Win95/98.                                 }
{                                                          }
{  Author: DayDream Studio                                 }
{  Email: haoem@126.com                                    }
{  URL: http://haoxg.yeah.net                              }
{  Last Modified DateTime: 2000/2/28 14:47                 }
{                                                          }
{**********************************************************}

unit CMOSTool;

interface

uses
  Windows, Messages, SysUtils, Classes, Forms, Dialogs;

const
  CMOS_MAX_DATASIZE = 255;
  CMOS_DEFAULT_DATASIZE = 255;

type
  TCMOSTool = class
  private
    FDataSize: Integer;
    procedure SetDataSize(Value: Integer);
  public
    constructor Create; overload;
    constructor Create(ADataSize: Integer); overload;
    destructor Destroy; override;

    property DataSize: Integer read FDataSize write SetDataSize;
    procedure GetCMOSData(P: TMemoryStream);
    procedure SetCMOSData(P: TMemoryStream);
  end;

function GetPort(Port: Word):Byte; stdcall;
procedure SetPort(Port: Word; Value: Byte); stdcall;

implementation

function GetPort(Port: Word):Byte; stdcall;
begin
  asm
    push edx
    push eax
    mov  dx, Port
    in   al, dx
    mov  @Result, al
    pop  eax
    pop  edx
  end;
end;

procedure SetPort(Port: Word; Value: Byte); stdcall;
begin
  asm
    push edx
    push eax
    mov	 dx, Port
    mov	 al, Value
    out	 dx,al
    pop	 eax
    pop	 edx
  end;
end;

constructor TCMOSTool.Create;
begin
  inherited Create;
  DataSize := CMOS_DEFAULT_DATASIZE;
end;

constructor TCMOSTool.Create(ADataSize: Integer);
begin
  inherited Create;
  DataSize := ADataSize;
end;

destructor TCMOSTool.Destroy;
begin
  inherited Destroy;
end;

procedure TCMOSTool.SetDataSize(Value: Integer);
begin
  if Value < 0 then Value := 0;
  if Value > CMOS_MAX_DATASIZE then Value := CMOS_MAX_DATASIZE;
  FDataSize := Value;
end;

procedure TCMOSTool.GetCMOSData(P: TMemoryStream);
var
  i: Integer;
  b: Byte;
begin
  P.SetSize(0);
  for i := 0 to FDataSize - 1 do
  begin
    SetPort($70, i);
    b := GetPort($71);
    P.Write(b, 1);
  end;
  P.Position := 0;
end;

procedure TCMOSTool.SetCMOSData(P: TMemoryStream);
var
  i: Integer;
  b: Byte;
begin
  P.Position := 0;
  for i := 0 to FDataSize - 1 do
  begin
    P.Read(b, 1);
    SetPort($70, i);
    SetPort($71, b);
  end;
  P.Position := 0;
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -