My task is to write a command line program, which has to try and delete a file which is in use.

The reason for this is because I am writing a tool which is used for removing malware, and it is very time consuming to have to load up a boot disk every time we want to remove one of these files.

Can anyone point me in the right direction for doing this.
I know that I can usually just delete the file on reboot, but even this sometimes doesnt work.

What you need is the API call (assuming windows here... *nix let's you do it without some kind of voodoo) MoveFileEx. MoveFileEx is an api called (I believe declared in windows.h) that allows you to move a file, even if the file is in use. This doesn't actually take effect until you reboot the machine, but the API flags the file for move. If you choose null as a destination, it deletes the file. The prototype is:
MoveFileEx(sSourceFile, sDestFile, MOVEFILE_DELAY_UNTIL_REBOOT).

Hope that helps.