Announcement

Collapse
No announcement yet.

Processing Callback From DLL

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Tom Hanlin
    replied
    And, oh yeah-- I wouldn't be fully confident in the calling
    convention here. Given that Et4CPrintHook uses the PASCAL
    convention, CPrintRoutine may be intended to follow suit, so
    CDECL may not be the right choice.

    ------------------
    Tom Hanlin
    PowerBASIC Staff

    Leave a comment:


  • Tom Hanlin
    replied
    No, the C function is returning a SHORT, which is an INTEGER in
    PowerBASIC.

    Assuming the C declaration of CPrintRoutine is correct... it
    rather looks like the whole COMPINFO structure is being passed
    on the stack. Unfortunately, you can't pass a user-defined type
    BYVAL in PowerBASIC. What you'd need to do would be to write a
    bit of assembly code to pull the parameter off the stack and
    to clean up the stack before returning.

    I'll see if I can put together an example.

    ------------------
    Tom Hanlin
    PowerBASIC Staff

    Leave a comment:


  • Michael Purkhardt
    replied
    Doug,

    Change your function to return a LONG as oppose to an INTEGER.

    -Michael-

    Leave a comment:


  • Doug Gamble
    started a topic Processing Callback From DLL

    Processing Callback From DLL

    I'm trying to interface to a third-party DLL to create and
    process ZIP files. I can make and extract ZIP files but now
    I want to display a progress bar during the processing. The DLL
    provides functions to define a callback routine to receive a
    message structure. When ever I make a program to process the
    callbacks it crashes.

    Here are the C header file structures and declares:

    Code:
    #define ETCP_MAX_FILENAME_LENGTH 255
    
    typedef struct tagCOMPINFO
    {
       UCHAR ciZipFileName[ETCP_MAX_FILENAME_LENGTH];     /* name of .ZIP file being processed */
       UCHAR ciFileName[ETCP_MAX_FILENAME_LENGTH];        /* name of the file being processed (added to .ZIP, deleted from .ZIP, or whatever) */
       short ciOperation;        /* operation: 0 zip, 1 unzip, 2 delete, 3 test */
       long ciTotalSize;         /* total number of bytes to process */
       long ciCurrentByte;       /* current byte being processed */
       long ciCompSize;          /* compressed size */
       short ciMethod;           /* compression method */
       short ciPass;             /* pass number [1..n] */
       long ciPassSize;          /* total bytes this pass */
       short ciMessageType;      /* message type (status, error, query) */
       short ciMessageCode;      /* message number (if error message) */
       short ciDiskNumber;       /* disk number (for multi-volume query) */
    } COMPINFO;
    
    void FAR PASCAL Et4CPrintHook (FARPROC CPrintRoutine);
    
    short CPRintRoutine(COMPINFO CPrintInfo);
    Here is what I'm using in PBDLL 6.0:

    Code:
    TYPE COMPINFO
      ciZipFileName AS STRING * 255
      ciFileName    AS STRING * 255
      ciOperation   AS INTEGER
      ciTotalSize   AS LONG
      ciCurrentByte AS LONG
      ciCompSize    AS LONG
      ciMethod      AS INTEGER
      ciPass        AS INTEGER
      ciPassSize    AS LONG
      ciMessageType AS INTEGER
      ciMessageCode AS INTEGER
      ciDiskNumber  AS INTEGER
    END TYPE
    DECLARE FUNCTION ZipHook CDECL LIB "COMPPL32.DLL" ALIAS "Et4CPrintHook" (BYVAL lpCPrintInfo AS DWORD) AS INTEGER
    
    '
    '
    '
    FUNCTION ZipStatusCallback (CInfo AS COMPINFO) AS INTEGER
       '
       '
       '
       MSGBOX "Callback" & FORMAT$(CInfo.ciCurrentByte)
       
    END FUNCTION
    I've have not been able to get this to work! I must be
    overlooking something but I'm not sure what. Can anyone
    please help!

    Thanks,

    Doug Gamble



    ------------------
Working...
X