Главная страница | назад





Article #16395: How can I determining if a given machine has a math coprocessor.

 Question and Answer Database

FAQ1395D.txt   How can I determining if a given machine has a math coprocessor.
Category   :VCL
Platform    :All
Product    :All 32 bit  

Question:
How can I determine in code if a given machine either has a math
coprocessor or if Windows is supplying emulation?

Answer:
Contrary to popular belief, not all 486/586/686/ and Pentium clones
have floating point units. Under Windows 3.1, applications could take
advantage of this knowledge and choose to do fixed point math or use
other means to improve preformance. The following example shows how to
check for the existance of a floating point unit under both Win16 and
Win32.

Example:

{$IFDEF WIN32}
 uses Registry;
{$ENDIF}

function HasCoProcesser : bool;
{$IFDEF WIN32}
var
  TheKey : hKey;
{$ENDIF}
begin
  Result := true;
 {$IFNDEF WIN32}
  if GetWinFlags and Wf_80x87 = 0 then
    Result := false;
 {$ELSE}
  if RegOpenKeyEx(HKEY_LOCAL_MACHINE,
      'HARDWARE\DESCRIPTION\System\FloatingPointProcessor',
      0,
      KEY_EXECUTE,
      TheKey) <> ERROR_SUCCESS then result := false;
  RegCloseKey(TheKey);
 {$ENDIF}
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  if HasCoProcesser then
    ShowMessage('Has CoProcessor') else
    ShowMessage('No CoProcessor - Windows Emulation Mode');
end;

7/16/98 4:31:28 PM
 

Last Modified: 01-SEP-99