As I mentioned previously, I have been experimenting with integrating our application with Maximizer CRM. Working with their SDK, it doesn’t take long to figure out that the com interfaces were designed with VB and C++ programmers in mind. Most of it works with VFP, but there are a few exceptions. I ran into a problem with an interface that accepts a variant variable by reference. I was surprised to find out that Fox can’t create a variant.
Shirley I can’t be serious? Everyone knows that all variables in Fox are variants. While that may be true, Fox can’t create a variable of type variant that can be passed to com components. Fox always assigns a type to a variable. Even a simple local myvariable statement creates a logical variable. Attempting to pass the variable by reference to a com component may result in a “type mismatch” error.
This isn’t entirely Fox’s fault. After all, should a COM component assume that the calling environment can create a variant? Microsoft concedes this is a problem in C++ with MFC components and recommends using ATL instead (see link below).
So, what can you do if you run into this situation? Ideally, the COM interface would be changed not to use variants, but I doubt Maximizer will change their interfaces, in place for years, just so I can use VFP. VB does allow you to create variables of type variant, so I created a VB wrapper component. VFP passes a string to the VB component, the VB component converts that to a variant and passes it to the Maximizer component. It’s not an ideal solution, but it works.
Prb: ActiveX controls passing variant* back to VFP cause error