-
Notifications
You must be signed in to change notification settings - Fork 3
Problem Statement
7-zip is designed in a way to be widely compatible. The objects within the 7-zip library are implemented using standard COM interfaces. However, the author has chosen to provide a custom version of CreateObject
routine, and do not provide a type library describing the COM interfaces used by the objects. This was a choice to avoid the requirement of registering and potentially falling into DLL hell.
For this reasons, we cannot activate a 7-zip COM interface in the same way we traditionally do with any other COM objects. Instead, we must determine the correct CLSID
, which usually can be mapped to a specific archive format and whether it's an extraction or a compression operation, provide both the CLSID
and appropriate IID
to the 7-zip DLL's exported CreateObject
function.
The next problem is that those interfaces are implemented using IUnknown
and are not Automation-compatible. Without a type library, those interfaces cannot be used by VBx codebase directly. In VBx world, that would have required doing one of the following:
- Author a compatible IDL file against the DLL and compile a type library using MIDL
- Using low-level API functions to build v-tables and call them (a la "lightweight COM objects")
- Modifying the original 7-zip's C++ source code to implement the rest of missing COM specifications
In all those cases, those would require additional skills & tools outside the language's ecosystem to bridge the gaps.
One of goals twinBASIC has is to be the best COM authoring tool and that requires working at the COM level, rather than at the Automation level (as VBx would require you to). The project demonstrates that by using twinBASIC and without any additional tools, we can implement the interfaces using twinBASIC. The 7-zip's interfaces are defined in the Abstract folder.
Those interfaces are then implemented by classes. For example, see ArchiveExtractor and Filestream.
To further demonstrate the flexibility, the project provides both a DllExport
function which can be then used by external codes by defining a Declare
statement (or the equivalent). This does not require any registration of the type library and can be used in a xcopy deployment.