unitmain.pas

来自「在delphi中实现windows核心编程.原书光盘代码核心编程.原书光盘代码」· PAS 代码 · 共 48 行

PAS
48
字号
unit UnitMain;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;
  function WJSReadDisk32(drv:byte;SecCount,SecStart:byte;Cylinder:word;Head:byte;buffer:pchar):boolean;stdcall;external 'Read32.dll';
  function WJSWriteDisk32(drv:byte;SecCount,SecStart:byte;Cylinder:word;Head:byte;buffer:pchar):boolean;stdcall;external 'Read32.dll';
  
var
  Form1: TForm1;
  
implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
var
   s:string;
   i:integer;
   buf:array[0..512-1]of char;
begin
   if not WJSReadDisk32($80,1,1,0,0,buf) then
      raise exception.create('Read错误');
   s:='';
   for i:=0 to 512-1 do
   begin
      s:=s+format('%.2x ',[integer(buf[i])]);
      if i mod 16=15 then s:=s+#13;
   end;
   showmessage(s);
   if not WJSWriteDisk32($80,1,1,0,0,buf) then
      raise exception.create('Write错误');   
end;

end.

⌨️ 快捷键说明

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