- - * - WhiteUnicorn - * - -




* #WhiteUnicorn/ StartPage/ Documentation/DelphiFAQ >


Frequently Asked Questions

How can I determining if a given machine has a math coprocessor.

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;



* #WhiteUnicorn/ StartPage/ Documentation/DelphiFAQ >



- - * - Anastasija aka WhiteUnicorn - * - - LJLiveJournal
PFPhotoFile