i want to make my program complete a task when the user begins shutdown

is that programme already running? Guess you have to solve that with C using events. Can't imagine that using the Linux-Kernel/the WinAPI with ASM is done in a few minutes.
Win and Linux are sending a kill-signal a soon as the user shutsdown the computer. Don't ask me how you can access this signal exactly but there should be some documents out there in the web.

When you want your programme to be started when the user suspends the computer then I just see the way to write another shutdown-programme. Use C to access the command "shutdown" (which is the command for shutdown), compile it, add an icon to it and place it on the desktop. When the user want's to shut down the computer he/she has to open your programme that runs a script and then suspends the PC.

Hope that helps. If it's what you are looking for, than ask again and try to explain your problem again.