Skip to Content
avatar image
Former Member

Using PrintEngine (CRPE32.dll) in CR2011 with String type parameter raises 'Error:502 Invalid text of object handle'

Currently we’re using Delhi 7 (VCL compoents) and Crystal Report XI R2 for our Reporting applications. As you may aware of the fact that Crystal Report VCLs is built by wrapping the CR Engine (crpe32.dll routines and data-structures) into various set of object oriented classes framework. (Note: we only use TCRPE compoent that is a pure wrapper of crpe32.dll routines and NEVER used RDC or Viewer control).

Our application is working fine with all the earlier O/Ss including Windows 7 however it’s failing on Windows 8/8.1 or Server 2012. When we researched the problem, we came to know that CR XI R2 wouldn’t work with Windows 8 due to some compatibility issues. Additionally VCLs is not supported by CR anymore however there is a link that provides sufficient information about how to upgrade your VCLs to use higher version of CR. So the only resolution we found so far is to upgrading our CR version from XI R2 to CR 2011 (not even CR 2008 as it also has some issues). Since CR 2011 is the last version that is backward compatible and shipped with PrintEngine library (crpe32.dll and its dependent dlls e.g. pvlocale etc).

I’ve successfully managed to convert the CR-XI VCLs to CR 2011 in Delphi 7. While testing the component, the biggest problem I’m facing is that whenever I try to pass a text/string value to a Parameter then it’s giving me “Error:502 Invalid text or object handle”. Other parameters (I tested only integers, floats, currencies so far) seem to be working fine. We use the following crpe32.dll’s API calls to bind the string parameter:

Call 1) Initializing the PrintEngine using PELoadCrpeDll routine that loads crpe32.dll and its dependent dlls. Then PEOpenEngine, PEOpenPrintJob and PELogOnServer dll calls.

Call 2) Allocating our parameter’s string handle using the following PEGetStringHandle dll routine.

  1. CrpeEngine.PEGetStringHandle(pStrParamValue, HwndStrParam, pStrParamLength) where pStrParamValue = PChar and HwndStrParam = HWND and pStrParamLength=SmallInt.

Call 3) Setting the parameter value using following PEAddParameterCurrentValueW dll routine:

PEAddParameterCurrentValueW(printJob, parameterFieldName, reportName, currentValue)

Where PrintJob = handle to job; parameterFieldName = pWideChar, reportName = pWideChar

and currentValue = PEValueInfoW that contains the following fields (bold-faced fields are assigned with the values returned by the previous calls):

PEValueInfoW = record

    structSize : Word;

    valueType : Word;   {a PE_VI_ constant}

viNumber   : Double;

viCurrency : Double;

viBoolean  : Bool;

viString   : PEVIStringTypeW;

viDate     : PEVIDateOrTimeType; {year, month, day}

viDateTime : PEVIDateTimeType; {year, month, day, hour, minute, second}

viTime     : PEVIDateOrTimeType; {hour, minute, second}

viColor    : DWord;

    viInteger : Smallint; {STRING LENGTH is stored here in case of String type param}

viC        : Char;

ignored    : Char; {for 4 byte alignment. ignored.}

    viLong : DWord;   {STRING HANDLE is stored here in case of String type param}


THIS CALL IS FAILING with error 'Error:502 Invalid text of object handle'

Has there any major changes done w.r.t. these data-structures and routines in the CR2011 Print Engine (crpe32.dll) that I’m missing? Please see if you could help me resolve this issue or let me know where I can get the development guide?

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    Jan 05, 2015 at 10:59 PM

    Hi Ravinder

    Updating to CR 2011 will not help as you do not have the header file (crpe.H) for CR 2011. And actually, there is no such thing for that version anyhow. Last header file to be released was in version 9 of CR (and this for OEM partners only). The fact that you were able to make things work with CR XI R2 was pure chance and luck.

    Your only option is to move your development to CR for VS or CR for Eclipse.

    - Ludek

    Senior Support Engineer AGS Product Support, Global Support Center Canada

    Follow us on Twitter

    Add comment
    10|10000 characters needed characters exceeded