Ruby DL Setup to send and receive windows messages?

A

awertyui

I am trying to send and receive messages between a ruby program and
another program. The end goal is to be able to send a message to the
other program to request data and the other program returns a message
saying where the data file is using Atom tables. Could anyone point me
in the right direction? I have been trying to use ruby dl but I never
seem to set it up right with anyting more complicated than the sleep
function. I always get this error "unexpected type 'W'" or one
similar to it. Here is what I have been trying so far with no luck.


require 'dl/import'
require 'dl/struct'
require 'dl/types'

module Win32
extend DL::Importable
dlload 'user32.dll'

typealias "WPARAM", "UINT"
typealias "LPARAM", "UINT"

POINT = struct [
"ULONG x",
"ULONG y"
]


MSG = struct [
"HWND hwnd",
"UINT message",
"WPARAM wParam",
"LPARAM lParam",
"DWORD time",
"POINT pt"
]

typealias "LPMSG","MSG*"
extern 'BOOL PeekMessage(LPMSG,HWND,UINT,UINT,UINT)'
extern 'UINT SendMessage(HWND,UINT,WPARAM,LPARAM)'


end
line = gets
 
T

Takaaki Tateishi

POINT = struct [
"ULONG x",
"ULONG y"
]


MSG = struct [
"HWND hwnd",
"UINT message",
"WPARAM wParam",
"LPARAM lParam",
"DWORD time",
"POINT pt"
]

As the type POINT can't be defined internally, you can't use it in the definition of "MSG".
I think the following definition will do for the purpose.

MSG = struct [
"HWND hwnd",
...
"ULONG pt_x",
"ULONG pt_y",
]
 

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,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top