Using an inout parameter from a DLL


#1

I have to call a function in a DLL using the dl library.

That function returns a status value and has a pointer to long as
inout parameter to return a value if successful. How do I declare
that type? How do I pass that parameter? How do I read the value
pointed to?

– fxn


#2

Hi,

parameter to return a value if successful. How do I declare that type? How
do I pass that parameter? How do I read the value pointed to?

– fxn

A little ugly but this works:

msg = DL.dlopen(“dlltest.dll”)
@func= msg[“Func”, “IL”]

in_value = 123
ptr = [in_value].pack(‘L’)
a = @func.call( [ptr].pack(“P”).unpack(‘L’).first )
out_value = ptr.unpack(‘L’).first

Regards,

Park H.