Help using ruby/dl to pass LPDWORD

Hi All,
I want to get the process ID by supplying the window handle to
the following API.

DWORD GetWindowThreadProcessId(HWND hWnd,LPDWORD lpdwProcessId);

However I am failing to understand how can I pass the Pointer to
DWORD to DL call object.

I tried passing PtrData object, but it does not seem to be returning
the PID value as I had expected. Following is my irb session:

irb(main):001:0> require ‘dl’
=> true
irb(main):002:0> rpid = 0
=> 0
irb(main):004:0> ptr =
=> #<DL::PtrData:0x2a05ce8 ptr=0x0 size=0 free=0x0>
irb(main):005:0> user32=DL.dlopen(“user32”)
=> #DL::Handle:0x2de7a90
irb(main):006:0> getpid = user32[‘GetWindowThreadProcessId’, ‘LLP’]
=> #<DL::Symbol:0x2a0d070 func=0x77d48a58 ‘long
GetWindowThreadProcessId(long, void *);’>
irb(main):007:0>, ptr)
=> [4032, [1180772, #<DL::PtrData:0x2a05ce8 ptr=0x0 size=0 free=0x0>]]
irb(main):008:0> p ptr
#<DL::PtrData:0x2a05ce8 ptr=0x0 size=0 free=0x0>
=> nil

I was expecting to ptr data to change to the pid of my process, however
it has not changed at all.

Am I missing something obvious. Is there any other way I can do this.

Thanks and Regards,

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs