Im getting the following
Access violation at address 00404340 in module 'test.exe'. Read of address FFFFFFD5
with the following code
var
List: TStrings;
In the Create Section:
List:= TStringList.Create;
Adding to the list:
Result := List.AddObject('hi', aCreatedObject);
MessageDlg(FunctionHookList.Objects[Result].ClassName, mtInformation, [mbOK], 0);
The Message dialog shows the correct classname
But later when i do,
i := list.IndexOf('hi');
if i >= 0 then
if list.Objects[i] <> nil then
if assigned(list.Objects[i]) then
begin
tmp := list.Objects[i];
if tmp <> nil then
MessageDlg(tmp.ClassName, mtInformation, [mbOK], 0); //*******
end;
i get the Access violation above at on the //******* line
I know there is a bit of duplicated code there, but i was trying to check ‘everything’
Please note that Assigned doesn’t check anything, except for nil. If you put an object in the stringlist, free it, and then check the stringlist, it will tell you that there’s still an object. Check this example:
So almost all your checks are valid, except the assigned. It only checks if the object contains any other value than nil, which it basically the same check you perform on the line above.