发信人: 20775613(呆久了爱上我) 
整理人: teleme(2004-01-02 16:21:56), 站内信件
 | 
 
 
 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);
 asm
   dw 310Fh
   mov TimerLo, eax
   mov TimerHi, edx
  end;
 
  Sleep(DelayTime);
  asm
   dw 310Fh
   sub eax, TimerLo
   sbb edx, TimerHi
   mov TimerLo, eax
   mov TimerHi, edx
  end;
 
  SetThreadPriority(GetCurrentThread, Priority);
  SetPriorityClass(GetCurrentProcess, PriorityClass);
  Result := TimerLo / (1000.0 * DelayTime);
 
  end;
 
   3.获取当前机器的所有物理内存
 
 function GetMemoryTotalPhys : Dword;
 
  var
   memStatus: TMemoryStatus;
 
  begin
   memStatus.dwLength := sizeOf ( memStatus );
   GlobalMemoryStatus ( memStatus );
   Result := memStatus.dwTotalPhys;
 end; 
 
  ----  阅读使人博学,辩论使人聪明,写作使人精明。           
   
   有咩事传纸仔给我呀!    
 从现在开始,拨打110**电话,即能获得7天全免食宿的牢房之旅,并可获赠精美手铐一副,享受来回警车接送。每天前十名打入者,还将与警犬嬉戏。 
   好处多多,礼物丰富,赶快拨打哦! 
            | 
 
 
 |