Here is a small function that extracts a string from a resource dll.
Works fine when the resource is there, and I get an EResNotFound When
one is not found. However when the code in the exception clause is run
(on EResNotFound do Result:= blank;) it immetiately gives an AV. In
fact it dos'nt matter what code I put in the exception I get the AV
I cant see what the problem is
Best wishe Ed.
function TformMainTasks.SetAnchorText(const ResString:string):string;
var
ls:Tstringlist;
ms:TresourceStream;
h:Thandle;
begin
try
h := LoadLibrary(pchar('strings.dll'));
try
ms:=TresourceStream.Create(h,ResString, RT_RCDATA);
if ( Assigned(ms)) then
begin
try
ls:= TstringList.Create;
ms.Position:= 0;
ls.LoadFromStream(ms);
Result:= ls.Text;
finally
ls.Free;
// free resources
end; // try/finally
End
Else Result:= blank;
except
on EResNotFound do Result:= blank;
end; // try/except
finally
ms.Free;
FreeLibrary(h);
// free resources
end; // try/finally
end;