PDA

View Full Version : How to receive a value from a dll?



Mauricio
06-11-2007, 07:05 AM
Hi all,
Following with my first script I need to encrypt a variable. I created a dll with a function, MCS_Encrypt and I call it in this way:

Call DLL "c:\Wsource\NEW_MCS_TEST\dlls\encrypt_test.dll" -- Function "MCS_Encrypt" (STRING,STRING) (%MCS_CLAVE%,%MCS_PASSWORD%)

The function returns a string and I would like to store this value in a variable (and then assign to %MCS_PASSWORD%).

I know that the prototype for my function could be (STRING, *STRING) but, for other reason, I can't use it.

Thanks in advance.

Mauricio

linder
06-11-2007, 08:18 AM
Mauricio,

If the DLL returns a value in the second parameter then it should be prototyped as (STRING, *STRING).

There is a similar function call in the "Call Dll.sb6" script example.

HTH,
Friedrich

Mauricio
06-12-2007, 01:40 AM
Hi Friedrich,
no, the prototype of my Clarion function is MCS_Encrypt(STRING,STRING),STRING. It receives 2 parameters and returns a string that I have to save to %MCS_PASSWORD%. In Clarion I would do this:

MCS_PASSWORD = MCS_Encrypt(MCS_CLAVE, MCS_PASSWORD).

Thanks again.

Mauricio

linder
06-12-2007, 02:09 AM
Mauricio,

How would you handle the above with the Clarion CALL() procedure or the Windows RunDll32 technique?

The return data type is always a numeric value.

I would suggest to change this (in your DLL) to:

MCS_Encrypt(STRING,STRING,*STRING),LONG

I think we could add a feature so the return value could be a pointer to the buffer. But I think it's not really required.

Friedrich

Mauricio
06-12-2007, 02:25 AM
Hi Friedrich,
ok, no problem, it will be easy for me to change the function.
Thanks for your help.

Mauricio