Hi All, I have a question about JNI that I'm hoping someone can shed some light on.
Background: I'm writing a small
Java program that interacts with Windows COM objects. The program invokes native methods in a .dll (that I wrote), which then uses MFC to interact with a COM object.
I have successfully written native methods that can create a COM object (given its CLSID), invoke a method on the COM object, and destroy the COM object.
I would like to keep a handle to a COM object in the native code. So when the method that creates a COM object is called, it obtains a pointer to an IDispatch interface and keeps it. When another method is called later to invoke a method on the COM object, the method is invoked on the instance that was created previously.
My Problem: The handle that is maintained in the native code seems to be global to the process (i.e. the VM). I can't figure out how to associate the pointer to the IDispatch interface with a specific instance of my Java object that is calling the native methods.
If any of that description is unclear or if you need more information, let me know! I'm new to JNI programming, so I might have left out information unintentionally.
Thanks in advance,
Will