找回密码
 注册
搜索
查看: 7636|回复: 0

变速齿轮Delphi实现

[复制链接]
发表于 2003-10-13 12:46:12 | 显示全部楼层 |阅读模式
{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.
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|宁德市腾云网络科技有限公司 ( 闽ICP备2022007940号-5|闽公网安备 35092202000206号 )

GMT+8, 2025-6-19 03:35 , Processed in 0.014237 second(s), 15 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表