Hi everyone.

I just finished a cryption project written in c++ WinApi, in my project I also use the registry.

My problem is this- I assigned a registry value that is 1 when the program is running, and 0 when the program is terminated (normally)- the code for turning the registry value to 0 is in the
" case WM_CLOSE: {...} " in the switch(Msg).
Hoping u understand me, I dont know how else to say this..
Anyway when you try to open the program when the registry value is set to 1, it doesn't allow it and prints out an error message, and here lies the problem- when the program terminats abnormally, the registry stays on 1, and the program cannot run (needed to be changed manually from the registry)..

how can I fix this? I thought about getting another variable, purhaps with 3 possiable values (for before program running, while, and after), but cannot think of anything that can fix this and combine the two functionalities- knowing if the program is running or not, and if the program terminated abnormally or normally...

Thanks for any help,
cheers!