Plex 2E

  • 1.  Attributes for Imported COM

    Posted Nov 22, 2011 12:51 AM
    Hello Community

    Cant get a component package (Zetafax) to compile..

    Firstly get this:
    Starting Build of ZfLib14ZfLib14_pkg - Release
    COMPILE : error C2039: 'IStream' : is not a member of 'ZfLib14'
                    c:\lokalmodeller\comimpo20121\source\ZfLib14.h - Line 2481
    COMPILE : error C2039: 'IStream' : is not a member of 'ZfLib14'
                    c:\lokalmodeller\comimpo20121\source\ZfLib14.h - Line 2485
    COMPILE : error C2039: 'ISequentialStream' : is not a member of 'ZfLib14'
                    c:\lokalmodeller\comimpo20121\source\ZfLib14.h - Line 2544
    Added a Attributes for Imported COM label
    include( "IStream", "ISequentialStream","tagSTATSTG" )
    It worked I did not get any C2039 errors again but a new set of errors:
    Starting Build of ZfLib14ZfLib14_pkg - Release
    COMPILE : error C2011: '_ULARGE_INTEGER' : 'union' type redefinition
                    c:\lokalmodeller\comimpo20121\source\release\obj\zfapi32.tlh - Line 1327
    COMPILE : error C2011: '_LARGE_INTEGER' : 'union' type redefinition
                    c:\lokalmodeller\comimpo20121\source\release\obj\zfapi32.tlh - Line 1348
    so with Compiler Error with #import Directive and the ADSI Type Library
    this in mind have been trial and error and to be honest being impatient and not really understanding what is going on just hoping I will stumble accross the magic combination

    Considering the header file looks like this now
    #include "ObComFld.h"
    #include "ObVariantFld.h"
    #include "stdole20.h"
    #import <C:\Program Files\Common Files\Equisys\ZFAPI32.DLL>  \
    
    
    raw_dispinterfaces  \
    
    
    rename_namespace( "ZfLib14" ) \
    
    
    include( "IStream", "ISequentialStream","tagSTATSTG" )
    I have tried
    #import <C:\Program Files\Common Files\Equisys\ZFAPI32.DLL> rename("_LARGE_INTEGER", "")
     rename("_LARGE_INTEGER", "")
     rename("_LARGE_INTEGER", "("_LARGE_INTEGER2")
    When Attributes for Imported COM label is set to (recommended in The #import Directive
    ) :
    include( "IStream", "ISequentialStream","tagSTATSTG" ) \
    rename( "_ULARGE_INTEGER", "_ULARGE_INTEGER2" ) \
    rename( "_LARGE_INTEGER", "_LARGE_INTEGER2" )
    I get the following compile errors that look that they might be https://support.ca.com/irj/portal/anonymous/kbproblem?productcd=CPLEX&problemnbr=1539 COM WRAPPER COMPILE ERROR C2664
    Starting Build of ZfLib14ZfLib14_pkg - Release
    COMPILE : error C2079: 'ZfLib14::tagSTATSTG::cbSize' uses undefined struct 'ZfLib14::_ULARGE_INTEGER2'
                    c:\lokalmodeller\comimpo20121\source\release\obj\zfapi32.tlh - Line 1327
    COMPILE : error C2664: 'ZfLib14::IStream::raw_RemoteSeek' : cannot convert parameter 1 from 'ZfLib14::_LARGE_INTEGER2' to 'ZfLib14::_LARGE_INTEGER2'
                    c:\lokalmodeller\comimpo20121\source\release\obj\zfapi32.tli - Line 973
    COMPILE : error C2664: 'ZfLib14::IStream::raw_SetSize' : cannot convert parameter 1 from 'ZfLib14::_ULARGE_INTEGER2' to 'ZfLib14::_ULARGE_INTEGER2'
                    c:\lokalmodeller\comimpo20121\source\release\obj\zfapi32.tli - Line 979
    COMPILE : error C2664: 'ZfLib14::IStream::raw_RemoteCopyTo' : cannot convert parameter 2 from 'ZfLib14::_ULARGE_INTEGER2' to 'ZfLib14::_ULARGE_INTEGER2'
                    c:\lokalmodeller\comimpo20121\source\release\obj\zfapi32.tli - Line 985
    COMPILE : error C2664: 'ZfLib14::IStream::raw_LockRegion' : cannot convert parameter 1 from 'ZfLib14::_ULARGE_INTEGER2' to 'ZfLib14::_ULARGE_INTEGER2'
                    c:\lokalmodeller\comimpo20121\source\release\obj\zfapi32.tli - Line 1003
    COMPILE : error C2664: 'ZfLib14::IStream::raw_UnlockRegion' : cannot convert parameter 1 from 'ZfLib14::_ULARGE_INTEGER2' to 'ZfLib14::_ULARGE_INTEGER2'
                    c:\lokalmodeller\comimpo20121\source\release\obj\zfapi32.tli - Line 1009
    COMPILE : error C2664: 'ZfLib14::IStream::RemoteSeek' : cannot convert parameter 1 from '_LARGE_INTEGER' to 'ZfLib14::_LARGE_INTEGER2'
                    c:\Lokalmodeller\ComImpo20121\Source\ZfLib14.cpp - Line 13441
    COMPILE : error C2664: 'ZfLib14::IStream::SetSize' : cannot convert parameter 1 from '_ULARGE_INTEGER' to 'ZfLib14::_ULARGE_INTEGER2'
                    c:\Lokalmodeller\ComImpo20121\Source\ZfLib14.cpp - Line 13505
    COMPILE : error C2664: 'ZfLib14::IStream::RemoteCopyTo' : cannot convert parameter 2 from '_ULARGE_INTEGER' to 'ZfLib14::_ULARGE_INTEGER2'
                    c:\Lokalmodeller\ComImpo20121\Source\ZfLib14.cpp - Line 13562
    COMPILE : error C2664: 'ZfLib14::IStream::LockRegion' : cannot convert parameter 1 from '_ULARGE_INTEGER' to 'ZfLib14::_ULARGE_INTEGER2'
                    c:\Lokalmodeller\ComImpo20121\Source\ZfLib14.cpp - Line 13727
    COMPILE : error C2664: 'ZfLib14::IStream::UnlockRegion' : cannot convert parameter 1 from '_ULARGE_INTEGER' to 'ZfLib14::_ULARGE_INTEGER2'
                    c:\Lokalmodeller\ComImpo20121\Source\ZfLib14.cpp - Line 13802
    COMPILE : error C2228: left of '.QuadPart' must have class/struct/union
                    c:\Lokalmodeller\ComImpo20121\Source\ZfLib14.cpp - Line 13911
    Finished Build of ZfLib14ZfLib14_pkg - Release with 12 error(s), 0 warning(s)
    but really must admit its hit and hope! Hopefully someone understands this..Jez.. :)

    Many thanks
    George




    Links I have found useful for future ref:

    The #import Directive
    Compiler Error with #import Directive and the ADSI Type Library

    COM WRAPPER COMPILE ERROR C2664
    Interop Forms Toolkit with COM Import

    Compiling stdole20 package after componet import

    Component import CodeJock 13.3 trial


  • 2.  RE: Attributes for Imported COM

    Posted Nov 22, 2011 06:12 AM
    [s]

    GeorgeJeffcock wrote:

    #include "ObComFld.h"
    #include "ObVariantFld.h"
    #include "stdole20.h"
    #import <C:\Program Files\Common Files\Equisys\ZFAPI32.DLL>  \
    
    
    raw_dispinterfaces  \
    
    
    rename_namespace( "ZfLib14" ) \
    
    
    include( "IStream", "ISequentialStream","tagSTATSTG" )
    Is it because I have managed to import the DLL of zetafax and not the

    "filename
    Allows you to specify which type library you want to import. filename can be one of the following:
    A type library (.tlb or .odl). file:, which indicates type library, can precede each filename. "

    Only point this out to help the knowledgeable as really hit and hope for me at the moment[s]

    A library (.dll) file containing a type library resource (such as .ocx). is allowed on import.


  • 3.  RE: Attributes for Imported COM

    Posted Nov 22, 2011 08:05 AM
    George,

    Try
    inject_statement("#undef _ULARGE_INTEGER") \
    inject_statement("#undef _LARGE_INTEGER") \
    instead of the rename

    Regards,
    Jeremy Hutchinson
    Desynit Limited
    :: Plex Wiki :: 2E Wiki ::
    :: Plex/2E Feed Aggregator ::
    :: Edge Forum Archive ::


  • 4.  RE: Attributes for Imported COM

    Posted Nov 22, 2011 08:13 AM
    apologises for calling you out directly but you have been so helpful on the other posts.

    Right my header file now looks like this after altering Attributes for Imported COM label as suggested.
    #include "ObComFld.h"
    #include "ObVariantFld.h"
    #include "stdole20.h"
    #import <C:\Program Files\Common Files\Equisys\ZFAPI32.DLL>  \
    
    
    raw_dispinterfaces  \
    
    
    rename_namespace( "ZfLib14" ) \
    
    
    include( "IStream", "ISequentialStream","tagSTATSTG" ) \
    inject_statement("#undef _ULARGE_INTEGER") \
    inject_statement("#undef _LARGE_INTEGER")
    But the error C2011 are back:
    Starting Build of ZfLib14ZfLib14_pkg - Release
    COMPILE : error C2011: '_ULARGE_INTEGER' : 'union' type redefinition
                    c:\lokalmodeller\comimpo20121\source\release\obj\zfapi32.tlh - Line 1334
    COMPILE : error C2011: '_LARGE_INTEGER' : 'union' type redefinition
                    c:\lokalmodeller\comimpo20121\source\release\obj\zfapi32.tlh - Line 1355
    COMPILE : error C2011: '_ULARGE_INTEGER' : 'union' type redefinition
                    c:\lokalmodeller\comimpo20121\source\release\obj\zfapi32.tlh - Line 1357


  • 5.  RE: Attributes for Imported COM

    Posted Nov 22, 2011 11:19 PM
    Try

    #import <C:\Program Files\Common Files\Equisys\ZFAPI32.DLL> exclude("_LARGE_INTEGER", "")

    error C2011 means 'LARGE_INTEGER' type is has been defined already.


  • 6.  RE: Attributes for Imported COM

    Posted Nov 23, 2011 05:21 AM
    Many thanks for helping out. a little bit of a puzzle.
    #include "ObComFld.h"
    #include "ObVariantFld.h"
    #include "stdole20.h"
    #import <C:\Program Files\Common Files\Equisys\ZFAPI32.DLL>  \
    
    
    raw_dispinterfaces  \
    
    
    rename_namespace( "ZfLib14" ) \
    
    
    include( "IStream", "ISequentialStream","tagSTATSTG" ) \
    #import <C:\Program Files\Common Files\Equisys\ZFAPI32.DLL> exclude("_LARGE_INTEGER", "") \
    #import <C:\Program Files\Common Files\Equisys\ZFAPI32.DLL> exclude("_ULARGE_INTEGER", "")
    And a new attribute 'exclude' and not 'rename' which I have tried and does get rid of the C2011 errors but leads to a new set (I used http://support.microsoft.com/kb/231271 as guidance)

    Unfortunately exclude seems not to get rid of the C2011 errors
    Starting Build of ZfLib14ZfLib14_pkg - Release
    COMPILE : error C2014: preprocessor command must start as first nonwhite space
                    c:\lokalmodeller\comimpo20121\source\ZfLib14.h - Line 33
    COMPILE : error C2011: '_ULARGE_INTEGER' : 'union' type redefinition
                    c:\lokalmodeller\comimpo20121\source\release\obj\zfapi32.tlh - Line 1327
    COMPILE : error C2011: '_LARGE_INTEGER' : 'union' type redefinition
                    c:\lokalmodeller\comimpo20121\source\release\obj\zfapi32.tlh - Line 1348
    COMPILE : error C2011: '_ULARGE_INTEGER' : 'union' type redefinition
                    c:\lokalmodeller\comimpo20121\source\release\obj\zfapi32.tlh - Line 1350
    but will try new variations using this new attribute (new to me!)

    Thanks
    George


  • 7.  RE: Attributes for Imported COM

    Posted Nov 23, 2011 03:08 AM
    OK, #undef wil not work as these are not macro definitions and so cannot be undefined.

    Let's see if what I've sent you directly works (without crashing!)...

    Regards,
    Jeremy Hutchinson
    Desynit Limited
    :: Plex Wiki :: 2E Wiki ::
    :: Plex/2E Feed Aggregator ::
    :: Edge Forum Archive ::


  • 8.  RE: Attributes for Imported COM
    Best Answer

    Posted Nov 23, 2011 09:31 AM
    Jez managed to get it to compile!! I had to send the actual DLL in the end but here is the working compile solution for others to see. I personally would never had been able to do it through trial and error!
    Ok George, lets see if this works – be prepared for it to crash your PC when run J.
    The issue that I can see is that LARGEINTEGER and ULARGEINTEGER are referenced as structs in the type library header. Eg.

    struct tagSTATSTG
    {
    LPWSTR pwcsName;
    unsigned long Type;
    struct ULARGEINTEGER2 cbSize;

    but are defined as union in the Winnt.h when MIDL_PASS is not defined.

    #if defined(MIDL_PASS)
    typedef struct LARGEINTEGER {
    #else // MIDL_PASS
    typedef union LARGEINTEGER {
    struct {
    DWORD LowPart;
    LONG HighPart;
    };
    struct {
    DWORD LowPart;
    LONG HighPart;
    } u;
    #endif //MIDL_PASS
    LONGLONG QuadPart;
    } LARGE_INTEGER;

    In the model ZfLib14._LARGE_INTEGER matches the structure definition.

    This is how I’ve got it to compile…

    In the model, rename ZfLib14._LARGE_INTEGER to ZfLib14._LARGE_INTEGER2 and ZfLib14._ULARGE_INTEGER to ZfLib14._ULARGE_INTEGER2. This is so the cpp file contains the correct names

    Set your attributes label to the following:
    include( "IStream", "ISequentialStream","tagSTATSTG" ) \
    inject_statement("typedef struct _LARGE_INTEGER2 { LONGLONG QuadPart; } LARGE_INTEGER2;") \
    inject_statement("typedef struct _ULARGE_INTEGER2 { ULONGLONG QuadPart;} ULARGE_INTEGER2;") \
    rename("_LARGE_INTEGER", " _LARGE_INTEGER2") \
    rename("_ULARGE_INTEGER", "_ULARGE_INTEGER2")

    This provides the the definition of our structures and the rename to ensure thye are used in the package.
    This all builds cleanly, but the real proof will be if ti runs without crashing.
    Kind Regards,
    Jeremy Hutchinson


    So in the end it invloved renaming objects in the plex model also, but I peronally think this import of coms is great even if it is a pain to get some packages to compile, i mangaged to get 3 or four previous packages to build but this defeated me so many thanks Jez, how about 50 quid a package Jez!