Windows run app on shutdown

Hi all,
   I don't do an huge amount of coding under windows, so this might be
a bit of a tourist question... so be it if it is.

I have been discussing under one of the various Delphi web forums ways
to have a program execute at windows shutdown.

The only sensible way I can think of to make this happen is to have a
program running in the background (maybe as a taskbar tray icon) and
simply do its thing when the windows shutdown event causes the program
to receive WM_QUERYENDSESSION

This is the solution proposed at:
http://community.borland.com/article/0,1410,16357,00.html

The problem here, of course, is that the program is sitting in memory
at all time doing... nothing, but taking up resources.

This bugs me I must say. This solution strikes me as a big, fat
work-around. Even if it is almost gospel (apparently).

There are even several shareware apps floating about which will sit
there and do this for you?!

So I thought that perhaps there is a way to put the path of the app in
the registry to be run on exit (such as the RUNONCE setting, but as a
RUNONSHUTDOWN.. or something...)
Or perhaps there is another way... an INI file in windows?

And then there is another option. I could go back to TP and leave
Delphi out of it, and run it on exit from the Windows GUI under the
CLI. I haven't thought about how to do this as a DOS mode app, but I
guess I would edit one of window's batch files?

I was wondering if some sagely person might be kind enough to comment
on this subject in general, and any ideas on how to achieve the
windows (GUI) mode version, and also possibly the DOS mode version,
and what you think may be the relative strengths ans weaknesses of
each.

(I am thinking both must be possible, as Norton Antivirus seems to use
the DOS mode solution to scan the floppy drives after the Windows GUI
shuts down, and the program ShutDownPlus from www.vwsoftware.com seems
to replace the windows shutdown dialog and achieve this effect -
although I haven't actually installed it to check this. I imagine that
it doesn't do this using the WM_QUERYENDSESSION tactic.)

Thanks in advance.

Best Regards,
    Mark.