I have a common code routine that displays in a listview, a list of files
together with their icons.
It keeps crashing with various error messages when displaying files from a
certain directory on my disk. The part of the code which produces the crash
is the part which gets the icon from the file.
function AddIcon(FileName:string; FileIndex:word):integer;
begin
FileIcon.Handle:=ExtractAssociatedIcon(hInstance,PChar(FileName),FileIndex);
if FileIcon.Handle <> 0
then Result:=ImageList.AddIcon(FileIcon)
else Result:=-1;
end;
This function adds the icon if it exists to the imagelist and then returns
the index into the imagelist, this is then assigned by the calling routine
to the listview item.
If the call to ExtractAssociatedIcon is commented out then the program runs
reliably, if it is left in then even if the rest is commented out, the
errors produced vary from Invalid pointer operation to Stack overflow,
Access violation and Invalid page fault.
D3.02, Win95OSR2, IE5
============================================
Patrick Dunford, Christchurch, NZ
http://patrick.dunford.com/
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz