+ 11

prevent close when exe red x button be clicked in c++

how to/can we prevent close when exe red x button be clicked in c++, example I want to make a file, run it,close it, then it must be deleted for protecting file's data(Example if the data is something important like as password), but if it closed before it deleted, the Important data can be revealed by user, so what I need is to prevent close when red X button clicked in exe(from c++) file, can we?

1st Dec 2016, 3:31 PM
Immanuel
Immanuel - avatar
1 Answer
0
You might get lucky with tmpfile: http://www.cplusplus.com/reference/cstdio/tmpfile/ This creates a FILE object you can read and write to, and (at least in the library implementations I've used) allows file sharing by default, so if you needed to run it or open it in another program, you should have no problem. Just don't call fclose on the returned object until you are done, as it deletes it right afterwards. But if you want to guarantee the file is erased even on abnormal program failure, you're going to be looking at a lot more complicated coding, typically OS dependent. I should warn you, though. When it comes to computer security, a dedicated hacker can eventually get to basically anything, given enough time. It might be worth investing in more complex security if a leak would hit heavily on your finances or personal security, but otherwise tmpfile should be fine. It'll keep out the casual snoopers.
7th Jan 2017, 2:37 PM
Nemo