I'm not too familiar with C++ at the moment, nor coding DLLs. There is probably an easier way to do with inside the DLL using C++, but here's an idea. Create a file every so many seconds that is update with what windows are open and their connection id, have the dll read from that file.. as I've said before there is probably an easier and better way to accomplish this.