Question How to receive a handle in an External Procedure

Estevan

New Member
Hello guys.

I'm calling an external procedure (WEBTAEncoderLib.dll) to encode a bank file (bank name: Bradesco, from Brazil).

In one of the methods to encode the file, I receive a handle value that I need to pass to another method.
Like this:
Method "fInitEncoder" return me a Handle.
This returned handle, I have to pass to the method "fWritedata".

My question is: how can I receive this "handle"? How is the datatype in Progress 4GL to a handle in an External Procedure?

1708449844339.png

Sorry about the documentation, but it just in Portuguese (because it's a Brazilian bank haha)

Thanks in advance!!
 

Cecil

19+ years progress programming and still learning.
It's been awhile since I've done any DLL stuff, but I belive that handles can be stored a LONG data types.

Example:

Code:
PROCEDURE fInitEncoder EXTERNAL "WEBTAEncoderLib.dll":
DEFINE input PARAMETER p-FileName AS Character.
DEFINE input PARAMETER p-Director AS Character.
DEFINE input PARAMETER p-KeyAS Character.
DEFINE input PARAMETER p-ErrOmessage AS Character.
DEFINE RETURN PARAMETER p-Return AS LONG.
END PROCEDURE.

I might have mixed some parameters but hopfully you get the gist.

 

Osborne

Active Member
As Cecil posted, I think LONG is what you are looking for. I have rarely interacted with DLL's but I have seen examples like these:

Code:
PROCEDURE GetSysColor EXTERNAL "user32.dll":
  DEFINE INPUT  PARAMETER nIndex    AS LONG.
  DEFINE RETURN PARAMETER iWinColor AS HANDLE TO LONG.
END.

PROCEDURE file_search EXTERNAL "dirsrch.dll":
 DEFINE INPUT        PARAMETER Search-Dir   AS HANDLE TO CHARACTER.
 DEFINE INPUT        PARAMETER File-Spec    AS HANDLE TO CHARACTER.
 DEFINE INPUT-OUTPUT PARAMETER File-List    AS MEMPTR.
 DEFINE INPUT        PARAMETER List-Size    AS LONG.         
 DEFINE OUTPUT       PARAMETER Missed-Count AS HANDLE TO LONG.
 DEFINE RETURN       PARAMETER Error-Val    AS SHORT.        
END PROCEDURE.

DEFINE VARIABLE iProcess      AS INTEGER     NO-UNDO.
DEFINE VARIABLE iWow64Process AS INTEGER     NO-UNDO.
DEFINE VARIABLE iResultValue  AS INTEGER     NO-UNDO.

RUN GetCurrentProcess( OUTPUT iProcess ).
RUN IsWow64Process( INPUT iProcess,
                    INPUT-OUTPUT iWow64Process,
                    OUTPUT iResultValue ).

PROCEDURE GetCurrentProcess EXTERNAL "kernel32.dll":
   DEFINE RETURN PARAMETER iProcess AS LONG.
END.

PROCEDURE IsWow64Process EXTERNAL "kernel32.dll":
   DEFINE INPUT        PARAMETER iProcess      AS LONG.
   DEFINE INPUT-OUTPUT PARAMETER iWow64Process AS HANDLE TO LONG.
   DEFINE RETURN       PARAMETER iResultValue  AS LONG.
END.
 

Estevan

New Member
Thanks for all replies!!
It worked for me receiving as a "INT64". But now I have a new problem: send a parameter as a "byte".

Considering the OpenEdge documentation, is not possible to receive/send a parameter as "system.byte".

Has anyone ever seen this before?
 

Cecil

19+ years progress programming and still learning.
you might be able to get away with an integer data type.

do you have any more documentation you can share of what you’re trying to achieve?
 

Estevan

New Member
I tried this before, but isn't work.
And I don't have any other documentation, just that in Portuguese:
1709150179575.png

There is an exemple in "C", but didn't help me:
int fWriteData(void *handle, const BYTE *data, const int dataLen, char *msgErro)
 
Top