Home > Back-end >  IsBadReadPtr function test
IsBadReadPtr function test

Time:09-24

Procedure TForm1. Btn1Click (Sender: TObject);
Var
Addr: DWORD;
The begin
Addr:=2;
If (not IsBadReadPtr (Pointer (addr), 4)) then ShowMessage (' 1 ')
The else ShowMessage (' 0 ');
end;
Normal operation, be sure it is ShowMessage (' 0 ')
But now there is a strange question, I got another computer up and running, will collapse, there are a great god can help

CodePudding user response:

Pointer on your computer (addr) is defined, but not on another computer to define or addr locking the addr resources, produce the Exception, as soon as you read the collapse of serious condition that is you,
Maybe try like this:
Var
Bad: Boolean;
Addr: DWORD;
The begin
Addr:=2;
Try
Bad:=IsBadReadPtr (Pointer (addr), 4);
Except,
Bad:=False;
end;
If (not Bad) then ShowMessage (' 1 ')
The else ShowMessage (' 0 ');

CodePudding user response:

https://msdn.microsoft.com/zh-cn/visualc/aa366713%28v=vs.85%29

This function has been abandoned, shouldn't be used again, oneself see a few specific reasons,
  • Related