Я продолжаю получать эту ошибку «Недействительная операция с плавающей точкой».Неверная операция с плавающей запятой
Я на Delphi 7.
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
TlHelp32, Dialogs, StdCtrls, ExtCtrls, Buttons, ComCtrls;
var //global
PHandle, cancel, bytes, scantype: integer;
...
procedure Tmain.scanbtnClick(Sender: TObject);
var max, address: Integer;
floatinput, floatinput1, floatinput2, datafloat: Real;
x: cardinal;
itm: TListItem;
begin
floatinput := StrToFloat(Trim(valueinput.Text));
floatinput1 := StrToFloat(Trim(valueinput1.Text));
floatinput2 := StrToFloat(Trim(valueinput2.Text));
if floatinput2 < floatinput1 then
begin
floatinput1 := floatinput1 + floatinput2;
floatinput2 := floatinput1 - floatinput2;
floatinput1 := floatinput1 - floatinput2;
end;
result.Show;
x := 0;
address := 0;
result.resultlist.Clear;
repeat
Application.ProcessMessages;
statusbar1.Panels.Items[1].Text := 'Searching... ' + IntToStr(address * 100 div max) + '% (' + IntToStr(address div bytes) + ' out of ' + IntToStr(max div bytes) + ').';
if ReadprocessMemory(PHandle, Ptr(address), @datafloat, bytes, x) then
begin
if (x > 0) then
begin
if scantype = 0 then
begin
if datafloat = floatinput then //error here
begin
itm := result.resultlist.Items.Add;
itm.Caption := '0x' + IntToHex(address,8);
itm.SubItems.Add(FormatFloat('0.0#########', datafloat));
end;
end;
if scantype = 1 then
begin
if datafloat > floatinput //also here
then begin
itm := result.resultlist.Items.Add;
itm.Caption := '0x' + IntToHex(address,8);
itm.SubItems.Add(FormatFloat('0.0#########', datafloat));
end;
end;
if scantype = 2 then
begin
if datafloat < floatinput //here too
then begin
itm := result.resultlist.Items.Add;
itm.Caption := '0x' + IntToHex(address,8);
itm.SubItems.Add(FormatFloat('0.0#########', datafloat));
end;
end;
if scantype = 2 then
begin
if (dataint <= intinput2) and (dataint >= intinput1) //even here
then begin
itm := result.resultlist.Items.Add;
itm.Caption := '0x' + IntToHex(address,8);
itm.SubItems.Add(FormatFloat('0.0#########', datafloat));
end;
end;
end;
end;
if x <> 0
then address := address + x
else address := address + bytes;
until (address >= Max) or (cancel = 1);
end;
Я даже проверил на окно центрального процессора, и это происходит потому, что его пытается загрузить значение с плавающей запятой из указатель, указывающий на нулевое значение.
Это не ReadMemory, потому что этот маленький фрагмент кода находится в цикле while и возвращает его перед запуском этой ошибки.
Что мне делать?
Заранее спасибо.
Каким типом данных является datafloat? Вы сравниваете его с вариантом (Null), но вариант не является типом, который был бы совместим с ReadProcessMemory. Вы хотите использовать Double? –
Код, который вы опубликовали, не будет компилироваться, так как единственное допустимое использование 'NULL' в Delphi - это использование вариантов. Пожалуйста, напишите полный ** код ** **, который вы используете. Просить нас отлаживать код, который на самом деле не является вашим кодом, является пустой тратой вашего времени и нашего. Опубликуйте компилируемый MCVE, который демонстрирует проблему, если вы хотите получить помощь здесь. –
@GerryColl данныеfloat реальный. Не могли бы вы объяснить мне, что именно происходит, когда я пытаюсь сравнить значение с нулем? – D3X