# Using an inout parameter from a DLL

**URL:** <https://www.ruby-forum.com/t/using-an-inout-parameter-from-a-dll/62811>\
**Category:** Ruby\
**Created:** [June 8, 2006, 11:14am UTC](https://www.ruby-forum.com/t/using-an-inout-parameter-from-a-dll/62811 "2006-06-08T11:14:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![fxn](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/77aa72/32.png) [@fxn](https://www.ruby-forum.com/u/fxn)\
**Post date:** [June 8, 2006, 11:14am UTC](https://www.ruby-forum.com/t/using-an-inout-parameter-from-a-dll/62811/1 "2006-06-08T11:14:14Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![fxn](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/77aa72/32.png) [@fxn](https://www.ruby-forum.com/u/fxn)\
**Post date:** [June 8, 2006, 12:03pm UTC](https://www.ruby-forum.com/t/using-an-inout-parameter-from-a-dll/62811/2 "2006-06-08T12:03:04Z")

</div>

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.
