Ruby 1.9.0 problem with DL.dlopen

C

Chauk-Mean P.

Hi,

The following code runs with ruby 1.8.6 (2007-09-24 patchlevel 111)
[i386-mswin32] on Windows :

require 'dl'
user32 = DL.dlopen('user32')
msgbox = user32['MessageBoxA', 'ILSSI']
msgbox.call(0, "Hello", "Message Box", 0)

A message box is displayed with just the OK button.

If I run the same code with ruby 1.9.0 (2007-12-25 revision 14709)
[i386-mswin32], the following error is output :

win_msgbox.rb:3:in `[]': wrong number of arguments(2 for 1)
(ArgumentError)
from win_msgbox.rb:3:in `<main>'

If I just remove the 'ILSSI' argument, this does not work either.

Thanks for any help.

Chauk-Mean.
 
C

Chauk-Mean P.

In case it would be useful for someone else, I received the following
answer from the development team :

--------------
Date: 18/01/2008 07:47
Expéditeur: Usaku Nakamura

Not a bug.
Date: 18/01/2008 07:47
Expéditeur: Usaku Nakamura

1.9's dl is not compatible with 1.8's.
The following code may help you:

require 'dl'
user32 = DL.dlopen('user32')
msgbox = DL::CFunc.new(user32['MessageBoxA'], DL::TYPE_LONG,
'MessageBox')
msgbox.call([0, "Hello", "Message Box",
0].pack('L!ppL!').unpack('L!*'))
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top