There is little memory left on the laptop, and it constantly decreases (sometimes it comes back). How can my program (using the Win API) monitor the creation of new files? Those. report in which folder and which program (process) created a new file, as well as the size of this file.

  • 2
    If your task is not programming, but “once to find someone who creates the file,” then use FileMon or another similar utility from sysinternals. - nick_n_a
  • Thanks for the program, but it's just interesting to run mine, I want to use winapi in practice. - Alexander Skusnov

2 answers 2

FindFirstChangeNotification() and others like her. You can register a notification for resizing files on disk.

  • I ask you to forgive me for arrogance, but could you add references to manuals or something similar, in which (in your opinion) this functionality is best described and how to work with it? - alexoander
  • Start @alexoander by reading the description of the specified function in MSDN. Somewhere there will be an example, just saying. - Vladimir Martyanov
  • Thank you, began to study this team, as well as change journals. I want to understand how these methods differ. - Alexander Skusnov

What you want is called a hook. An example of creating a hook just for the file creation function can be found here: https://stackoverflow.com/questions/6066857/hook-createfilew In a nutshell you can’t describe it.

  • one
    You do not need a hook, there is a ready notification mechanism. - Vladimir Martyanov
  • So I'm behind the times - Smithson
  • The necessary APIs appeared in XP as well ... - Vladimir Martyanov