Archive for October, 2009

Windows 7 Disappearing Desktop Shortcuts

Wednesday, October 21st, 2009

If you create shortcuts to files on a removable drive or a network share on your Windows 7 desktop you will eventually find that your shortcuts just up and disappear from time to time.  This is because the good folks in Redmond decided to automatically schedule a process that “cleans up” your system for you.  Among the many things that it does is delete “broken” and “unused” shortcuts from your desktop.  Broken shortcuts are those that are unavailable, for any reason, at the time the cleanup program runs.  Unused shortcuts are simply those that you haven’t used for a while.  The cleanup program does this without so much as a by your leave and doesn’t even bother to tell you that it has done anything at.  How rude!!

To prevent this from happening, you  need to disable the cleanup program.  To do this:

  1. Start the task scheduler.  Start | All Programs | Accessories | System Tools | Task Scheduler.
  2. Expand the tree in the left hand pane until you get to Task Scheduler Library | Microsoft | Windows | Diagnosis.
  3. In the right hand pane, right click the task named Scheduled and click Disable.

Now the automatic cleanup will no longer run.  Of course, this also prevents the cleanup of various log files so your disk space will slowly start to disappear but I figure this is a small price to pay for a consistent looking desktop.

Indy “Connection Closed Gracefully” Errors

Monday, October 5th, 2009

I was being plagued by “Connection closed gracefully” errors in an application that uses the Indy TIdHttp component to communicate with a remote server.  Periodically, I would get one of these exceptions.  Basically, this should be no big deal.  It just means that the remote server closed the connection before the transaction was complete.  i.e. I had sent the request but before I got the response, the remote server closed the connection.  So, just close the connection and try again after a suitable interval you say.  Well that is what I thought, but calling TIdHttp.Disconnect, waiting a bit and sending the request again just resulted in the same error over and over and over and over …

It turns out, that if there is any data left in Indy’s input buffer simply calling disconnect doesn’t actually get rid of the connection.  The connection lingers on until the input buffer is emptied.  In order to get rid of the connection completely you need to flush the input buffer by calling TIdHttp.IOHandler.InputBuffer.Clear after calling TIdHttp.Disconnect.  Completely inobvious and  not documented at all as far as I can tell.