How to get THE PATH of a newly created file C++?
That means my program will run in the background and if I
right click -> New Text Doc
a new file is created, right?
So my goal is that my program should get the path of that newly created file and store its path to a text document!
It's not exactly what you're looking for but "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\RecentDocs\..." will give you a list of the recently opened documents. Otherwise I suspect you're looking at hooking the "CreateFile()" function which is messy.
This is not a question about language, but a question about the Desktop Manager or OS.
You click with mouse some GUI element (of Windows Explorer), as a result some program executes. Only the Windows Explorer knew what it was doing. You select "Save" from Notepad. Notepad knows what it does, and so does the OS kernel/filesystem.
The question is, how can you ask them? Can you? Apparently yes: the antivirus applications can hook into the system calls and intercept file access. Presumably the OS documents the API to do so. Find that documentation.
Looking from other angle, you have a program, it runs, and asks where its own file actually is. Even that is not trivial on all platforms.