程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> Delphi >> 變速齒輪Delphi實現

變速齒輪Delphi實現

編輯:Delphi
D7+Win98,不能用於2000}
  unit MainUnit;

  

  interface

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

  type
  TForm1 = class(TForm)
  Button1: TButton;
  Button2: TButton;
  Button3: TButton;
  procedure Button1Click(Sender: TObject);
  procedure Button2Click(Sender: TObject);
  procedure Button3Click(Sender: TObject);
  private
  { Private declarations }
  public
  { Public declarations }
  end;

  var
  Form1: TForm1;

  implementation

  {$R *.dfm}
  procedure speed(count:Word);stdcall;
  const
  ExceptionUsed=$03;
  var
  IDT:array [0..5]of byte;
  lpOldGate:dWord;
  begin
  asm
  sidt IDT
  mov ebx,dWord ptr [IDT+2]
  add ebx,8*ExceptionUsed
  cli
  mov dx,Word ptr [ebx+6]
  shl edx,16d
  mov dx,Word ptr [ebx]
  mov [lpOldGate],edx
  mov eax,offset @@Ring0Code
  mov Word ptr [ebx],ax
  shr eax,16d
  mov Word ptr [ebx+6],ax
  int ExceptionUsed
  mov ebx,dWord ptr[IDT+2]
  add ebx,8*ExceptionUsed
  mov edx,[lpOldGate]
  mov Word ptr [ebx],dx
  shr edx,16d
  mov Word ptr [ebx+6],dx
  jmp @@exit

  
  @@Ring0Code:
  mov al,$34
  out $43,al
  mov ax,Count
  out $40,al
  mov al,ah
  out $40,al
  iretd
  @@exit:
  end;

  end;

  procedure TForm1.Button1Click(Sender: TObject);
  begin
  speed($6000);//慢
  end;

  procedure TForm1.Button2Click(Sender: TObject);
  begin
  Speed($1044);
  end;

  procedure TForm1.Button3Click(Sender: TObject);
  begin
  speed($500);
  end;

  end.
  

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved