Good morning. Got a problem been bugging my program for ages. It raises its ugly head sometimes when in the FormCloseQuery event, and is one specific item. Here goes (shortened for brevity)............
DirMonitor1: TDirMonitor; DirMonList: Tcomponentlist; procedure TMainform.DirMonArrayAdd(WatchDir: string); var Tval: Integer; CurrDir, PathVal, NameVal: string; DriveVal: Char; begin DirMonitor1 := TdirMonitor.create(self); DirMonList.Add(DirMonitor1); TDirMonitor(DirMonList.Items[DirMonList.count - 1]).Directory := CurrDir; TDirMonitor(DirMonList.Items[DirMonList.count - 1]).Onchange := DirMonitor1Change; TDirMonitor(DirMonList.Items[DirMonList.count - 1]).FilterNotification := [nfFILE_NAME, nfSIZE, nfLAST_WRITE]; TDirMonitor(DirMonList.Items[DirMonList.count - 1]).FilterAction := [faADDED, faMODIFIED]; TDirMonitor(DirMonList.Items[DirMonList.count - 1]).WatchsubTree := RxChecklistBox12.Checked[1]; end; Then in FormCloseQuery I have tried all combinations of below: // DirMonArrayStopStart(False); //this tells it to stop monitoring // DirMonitor1.Free; // DirmonList.Clear; FreeandNil(DirMonitor1); // FreeandNil(DirMonlist); DirmonList.Clear; raises an exception every time. With FreeandNil(DirMonitor1); being the least offensive. If anyone can solve this riddle appreciate - I'd love to buy you a beer! Alistair+ --------------------------------------------------------------------------- New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED] Website: http://www.delphi.org.nz To UnSub, send email to: [EMAIL PROTECTED] with body of "unsubscribe delphi" Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/