打印本文 打印本文 关闭窗口 关闭窗口
Delphi三十六之硬件篇
作者:武汉SEO闵涛  文章来源:敏韬网  点击数858  更新时间:2009/4/23 18:24:40  文章录入:mintao  责任编辑:mintao
  1 .端口读写

function ReadPortB( wPort : Word ) : Byte;

 begin
  asm
  mov dx, wPort
  in al, dx
  mov result, al
 end;

end;

procedure WritePortB( wPort : Word; bValue : Byte );

 begin
  asm
 
   mov dx, wPort
   mov al, bValue
   out dx, al
 end;

end;

  2.获知当前机器CPU的速率(MHz)

function CPUSpeed: Double;

 const
  DelayTime = 500;

 var
  TimerHi, TimerLo: DWORD;
  PriorityClass, Priority: Integer;

 begin
 PriorityClass := GetPriorityClass(GetCurrentProcess);
 Priority := GetThreadPriority(GetCurrentThread);
 SetPriorityClass(GetCurrentProcess, REALTIME_PRIORITY_CLASS);
 SetThreadPriority(GetCurrentThread, THREAD_PRIORITY_TIME_CRITICAL);
 Sleep(10);

打印本文 打印本文 关闭窗口 关闭窗口