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.
7223c62b7310e164eb79c740188abbda?d=identicon&s=25 Xavier Noria (Guest)
on 2006-06-08 11: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
E51d56251ec4affafe85ee9367228965?d=identicon&s=25 Park Heesob (Guest)
on 2006-06-08 12: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 Heesob
This topic is locked and can not be replied to.