Using a PID is easy and commonly used on UNIX, but it might bite you if you port that to Windows if you want the file to survive after the program. On UNIX the PIDs cycle around, and it will be "a long time" before your PID gets reused, but on Windows a PID can get reused by the next process that starts.