From: "daniel åkerud" Date: 2008-01-25T05:45:39+09:00 Subject: Re: Using a DLL that wants a function pointer ------=_Part_24089_21407004.1201207544157 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline On Jan 24, 2008 7:45 PM, yermej wrote: > On Jan 24, 9:10 am, daniel =E5kerud wrote: > > [Note: parts of this message were removed to make it a legal post.] > > > > I want to use a DLL with Ruby (Win32). This DLL has X number of > functions, > > and one of these takes a function pointer. The DLL will call this > > callback-function when some data arrives. I cannot figure out how to do > this > > in Ruby. Is it possible? If not, any tips on how to circumvent this > > restriction? _Any_ hints appreciated. > > > > /D > > I haven't tried it before, but look into Win32::API::Callback. Most of > my googling returned threads where people were having problems with > it, but that might give you examples to get started with. Here's one > of them: > http://rubyforge.org/pipermail/win32utils-devel/2008-January/000985.html > > Look for where SNMPAPI_CALLBACK is defined. It appears that Callback > takes two arguments - the first is the parameter signature notated the > same as when you use an API method. The second would be the return > signature. Following that is the body of the callback as a block. > > Thanks for the answers, Today I have been working with creating Ruby extensions, and I got this idea: What about I pass a Proc.new object to a method in the extension, and when the extension gets a callback from the DLL, it calls the Proc object. This would work right? I havn't seen an example of an extension that manage= s a Proc object though and calls it, but if someone says this sounds reasonable i'll do this. /D ------=_Part_24089_21407004.1201207544157--