giobradja
23rd February 2007 08:20 UTC
System::Call problem
Hello everyone.
I'm using the System::Call to call a function from a DLL and get back some output. I've succesfully get back ulong values but I can't get back a byte array. the syntax i use is:
System::Call "${ROCKDLLNAME}::Rockey(i,*i,*l,*l,*i,*i,*i,*i,*t)i (${RY_READ},r4,,,0,24,,,r5) .r0"
The prototype of the function that is called is
WORD Rockey(WORD function, WORD* handle, DWORD* lp1, DWORD* lp2, WORD* p1, WORD* p2, WORD* p3, WORD* p4, BYTE* buffer);
In the past I have done the same thing with success when calling an other DLL. The only difference is that in that case buffer was declared as "ULONG* buffer". Has this enything to do?
Any help will be appreciated!
Thanx
Giorgio
kichik
23rd February 2007 11:58 UTC
You shouldn't use `*t` for `BYTE*`. That's for `char **`. If it's really a byte array and not a string, you should allocate a buffer and pass its address as `i`.
giobradja
23rd February 2007 14:03 UTC
The buffer IS actually a string. I store information in it and I can get them back from PowerBuilder (RAD) where the function prototype is declared as character array.
Anyway if I allocate a buffer and pass its address as i, how can I convert it to a string? It is sure that the contents of the buffer are 24 numbers, something like '0126582254...'.
Thanx for your time.
kichik
23rd February 2007 14:13 UTC
If it's a string, simply use `t .r5` instead of `*t r5`. It's a pointer to a buffer, not a pointer to a pointer and you want the output and not the input.
giobradja
23rd February 2007 14:29 UTC
You are a MAJOR player. After 24 hours of pain, finally there is a spark in the dark.
Thanx for your help.