Forum: Ruby using an inout parameter from a DLL

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Xavier N. (Guest)
on 2006-06-08 13:14
(Received via mailing list)
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
Park H. (Guest)
on 2006-06-08 14:03
(Received via mailing list)
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.
This topic is locked and can not be replied to.