When you say 'power off the computer', if you're talking about the same thing as pulling the plug out the back then no - there's no way to capture this.
The second best option to figure out if this happens is to do something once the power has come back on. It's fairly easy for a program to determine if it never went through it's OnClose routine.
The best option to track this is to install a UPS. UPS's come with either a serial cable or USB connection that allows the UPS to communicate to Windows or the UPS software that it has gone on to battery. I imagine it is possible to use the UPS DLLs to have your program notified that the power has failed. Your program could then do whatever, then shutdown the computer.
You can also tell Windows what to do when the Power button is pressed (ATX and ACPI only). Windows XP by default sets itself up to run it's shutdown routine when the power button is pressed. Windows 98 doesn't, but can be told to do so - you may have to install the ACPI drivers for this to work though.