3

How could I monitor an audio file being opened/run by another program in C++ on windows?

I've searched and the only thing I came up with is to check if the audio file is currently open, however this wouldn't be too accurate or efficient because the audio file is short and is opened multiple times. I want to catch every time it's opened.

I've read similar questions on here. But the 2 questions that were similar to my question were for Linux.

tshepang
  • 12,111
  • 21
  • 91
  • 136
ZC8
  • 33
  • 3
  • 1
    [How to check if a file is already open by another process in C?](http://stackoverflow.com/questions/1951791/how-to-check-if-a-file-is-already-open-by-another-process-in-c)? – Roman R. Oct 20 '12 at 17:44
  • Thanks, Roman R. I just read through that thread and it seems like monitoring a file without using hooks or a driver would be unreliable. – ZC8 Oct 22 '12 at 18:47

1 Answers1

1

C++ isn't the right tool to do this. If you really want to check out files in detail, you need to write a file filter driver (or a minifilter), which is not an easy thing.

Here is a little overwiew of how to start and this is a nice tutorial, which provides a first view.

An other (but maybe dirty) way is to try it using an api hook, but I wouldn't do this, because it affects the whole system and can lead to serious troubles.

Community
  • 1
  • 1
marscode
  • 373
  • 1
  • 4
  • 10