Support licensed object instantiation with IClassFactory2
We've been using com4j happily for years but the software we integrate with is about to start requiring a license key and we're trying to figure out if that's something com4j supports or could be modified to support easily. The examples we were shown for passing the license key are in C# and use CoGetClassObject (https://msdn.microsoft.com/en-us/library/windows/desktop/ms684007(v=vs.85).aspx) to get an instance of IClassFactory2 (https://msdn.microsoft.com/en-us/library/windows/desktop/ms680095(v=vs.85).aspx), on which they call CreateInstanceLic (https://msdn.microsoft.com/en-us/library/windows/desktop/ms694342(v=vs.85).aspx) to get an instance of the actual COM interface needed.
My research so far leads me to believe that the IClassFactory2 method of instantiation is at a lower level than what com4j provides, and library internals would have to be augmented to allow passing the license key in from Java.
Can anyone confirm this?
Thanks!
Yes, I believe it's true that com4j cannot support this as is. com4j only creates objects using CoCreateInstance.
One thing you might be able to do as a workaround is to use something like JNA to call CoGetClassObject, and then use COM4J.wrap to take ownership of the pointer and convert it to a IClassFactory2
I saw that method the other day while looking through the code. I'll see if I can get it working that way.
We need this same functionality. Has anyone had any success with the work-around using JNA?