A few points:
If 100% reliability is needed, this is not possible. It's a "race condition". There is currently no way to atomically open a window while simultaneously syncing the existence of that window to the filesystem. Imagine this sequence of events, in chronological order from earlier to later:
- You open an application, or an application opens a new window.
- The Windows API provides notification to the "monitoring program" telling it about the existence of a window.
- Power is cut before the "monitoring program" is able to write the fact that the window is there to "persistent storage"; that is, the hard drive.
In the general case, no third-party program can know the reason why a program has opened a given window. At a programming level, a program can decide to open a new window for any reason at all, or for no reason. Given this fact, the third-party program cannot know what steps are necessary to cause the window-opening program to open new windows.
For specific applications, this can be done. For example, for Microsoft Word, there are ways to read window titles and infer the names of open documents, or even install a Word Add-In that monitors the open windows and keeps track of open documents, then re-opens them on reboot.
However, when looking for such a solution, you would have to make sure that the "monitoring program" is able to understand the windowing strategy of each application you want to automatically re-open, and also understand the process for asking that application to re-open all of those windows.
One "naive" way to approach this would be to keep track of all the running programs that have created one or more windows, and then "stupidly" launch those executables when you restart your computer. It would be fairly simple to write such a program, and in fact, I'm sure many such programs exist. The downside is that it's probably not that useful -- how useful to you would it be if
notepad.exe launched when you started Windows, with no document open? That is basically the extent of what you can do in "the general case".
If you're in the middle of editing a document in Notepad or Word or any other editor program, and your PC suddenly shuts off, there is no reliable way to retain all of your data. If you are hoping for a software solution for this, keep hoping. It's better to buy an Uninterruptible Power Source (UPS), which is basically a big battery attached to your PC that prevents your PC from losing power if the main electricity is brought down or temporarily faults. Typically a UPS can keep your PC running long enough for you to save your work and shut down.
There is one way, in principle, to get better data integrity, but it is an implementation detail of a text / document editor: if the editor writes your changes to disk every single time you type a character or make a change, then the most data you can lose is one character (you typed the character and it couldn't get out to disk before you lost power). The way most editors work today, however, you may lose several minutes worth of data (in the case of AutoSave), or all of your data (in the case of editors without AutoSave).
I Don't Give Software Recommendations ;)
Something that "just keeps track of which files you have open in Notepad" is doable, but it's probably even easier to use a real text editor that remembers which files you have open without third-party plugins, such as Notepad++.