That would be an alert from the Operating System, not a language like C++.
If you are talking about Windows, then I know kernel mode code can get notifications, but not user mode code. This means a driver could get notified, but not a regular application. You must therefore program a driver for this particular application.
C++ is only concerned with manipulating the program itself. It cannot assume that it's run on an operating system that allows multiple programs to run simultaniously.
If you want to this program to work with other programs, you'll need an interface to the operating system.