Calling NamedPipes from DLL

 

Hello everyone!

 I've made a library in C++ that is responsible for everything I need to use Named Pipes. I want to integrate MT4 with Java application, from where I'm also calling functions from DLL. There is a problem : since I read messages pending on pipes from MetaTrader EA everything works, but when i call the same function from Java app, it throws an error (ID: 6 - The handle is invalid).  Is it possible that using one DLL from 2 programs is causing this problem? If not - what do you think could be wrong?

Reason: