Pass a structure to external DLL

Posted by bart.syryn on 30-Mar-2012 06:49

Hi folks,

I hope someone can help me out.

I've been looking in PSDN-history, also the Peg-history but I'm stuck with a problem.

I'm testing a Canon Cheque Scanner (CR-190i).  From openedge I can get the scanner working etc by calling external procedures in DLL (delivered by Canon).  Problem is, that the scanned image is in the memory of the scanner and I want to read out the image and save it to disk.

To do that the external DLL has following procedure :


Where :

LPCEIIMAGEINFO a memptr is that I could read from a procedure in the DLL and


typedef struct tagCEIIMAGEFILEINFO {
  size_t cbSize;             /* Size of CEIIMAGEFILEINFO */
  long   nFileType;         /* File format */
  long   nCompType;     /* Compression type */
  long   nPage;             /* Page */
  long   nJpegQuality;   /* Quality of JPEG compression */

    CSD_TIFF_FILE              TIFF file format

    CSD_JPEG_FILE            JPEG file format
    CSD_BMP_FILE             BMP file format
    CSD_COMP_NONE        No compression. Used only if nFileType is CSD_TIFF_FILE or CSD_BMP_FILE.
    CSD_COMP_MMR          MMR compression. Used only if nFileType is CSD_TIFF_FILE.
    CSD_COMP_JPEG         JPEG compression. Used only if nFileType is CSD_TIFF_FILE or CSD_JPEG_FILE.
  nPage                nPage can be used only for TIFF file. If nPage is zero, the file is overwritten with the image. If nPage is -1, the page is added to the end of the multi-page tiff file.

  nJpegQuality  Used only if nCompType is CSD_COMP_JPEG. Valid

Question is : how can I place this in a memptr so I can call the 'CsdSaveImageEx' procedure.

I've seen P7765 in the knowledge base, but I just can't get it work.

Strange for me is also that, for example nFileType is a 'long' and in the manual it suggest to send CSD_JPEG_FILE which is a character.

In the attached file I've placed the complete section of the Canon manual SDK and also an example of VB-codes that works.

Any help would be very much appreciated !

Kind regards

Bart Syryn


All Replies

Posted by jankeir on 30-Mar-2012 09:48

I believe you'll need a combination of set-size and put-string, put-long,...

There is some info in here:

Posted by gus on 02-Apr-2012 14:07

The first element of the structure (size_t) is either a 4 octet integer or an 8 octet integer, depending on whether you are running a 32-bit executable or a 64-bit executable. The others are all 4 octet integers (the same as INT in the 4GL).

So the first element starts at offset 0 in the structure.

The second starts at offset 4 or 8 and is 4 octets long. Threst are the same as the second.

You need to size the memptr at 20 or 24.

This thread is closed