Perhaps I missed something, but it looks like you created a process to retrieve the joystick data. To save yourself some trouble, replace that process with the C DLL suggested in the comments. Your main C++ application can then simply call a function within that DLL to retrieve the joystick data without even worrying about locks or inter-process communication.
Of course, if you do need two processes, you'll need to use shared memory in the DLL and process-level locks. Shared memory is needed because DLLs are loaded separately into each process's virtual space; nothing is shared, hence the need for shared-memory.