You have the following constraints:
- You cannot execute 32 bit and 64 bit code in the same process.
- The third party code is supplied in binary form, as 32 bit modules.
From this you can conclude that the third party code must run in a 32 bit process. This means you have the following options:
- Convert your process to 32 bit if that is possible. This is far and away the easiest solution.
- Leave your process as 64 bit, and run the third party code as a separate process.
The ugly solution you describe in the question is one way to implement option 2. But there are less ugly ways to do that. Instead of communicating using external files, you can use a remote procedure call mechanism (RPC).
There are plenty of options but the most obvious one is COM. Put the 32 bit code into an out-of-process COM server and consume it from your 64 bit application. This will let you write clean code that communicates to the third party library using method calls. The underlying RPC mechanism does all the low-level heavy lifting involved with getting information between the two processes.