Migrating to DataFlex 2021, Part 3
Lesson 16 – Com Class Generator
- The Com Class generator is a handy tool to generate classes for a COM object. In DataFlex 2021, this can now be done for 64-bit COM objects.
- From the Studio menu, select File > New > Class. Then select ‘Import COM automation’ from the choices.
- A list with available COM objects pops up. Check that the selected platform is the one needed the project. Currently it only lists the 64-bit COM objects. If 32-bit is selected, then the list of 32-bit COM objects is shown. The resulting 32-bit and 64-bit classes can be the same. In fact, they often are.
- The wasclnt.dll COM component is selected, click OK.
- The class file that has been generated is shown. Next, go to its source location and rename it.
- Then do the same thing again, but now for 32-bit.
- When the two files are compared, they are identical except for the location of the input COM object.
- When they are identical only one is needed, which works for both 32- and 64-bit COM objects. The reason that they are the same, is that the COM Class generator has applied the Longptr datatype, and it applied the OLE_VT_INT_PTR define.
- This is defined in Variant.pkg to be either I4 or I8, depending on the platform.
- Here is the list of supported platform dependent C types that convert to either Longptr or ULongptr.
- Converts to Longptr: INT_PTR, LONG_PTR, LPARAM, HMODULE.
- Converts to ULongtr: ULONG_PTR, UINT_PTR, WPARAM.
- In a few cases, the two generated files will differ. That occurs when a compiler switch has been used to define the interface to the outside in the COM component sources. In that case, there are two options. The two class files can be combined into one and IS$WIN64 is used to switch compilers, or the two files are kept, and the compiler switch is used when including the class file.
This is the end of this lesson and the end of this course on Migrating to DataFlex 2021. I hope the course helps you migrating to this new and exciting Dataflex version and takes away some hurdles for moving to 64-bit and Unicode. Thank you for watching.