From: Lloyd Linklater Date: 2008-01-25T03:22:42+09:00 Subject: Re: Using a DLL that wants a function pointer daniel 奪kerud wrote: > 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. It is with fear and trembling that I post here, but I did not want nothing to be said, so take this with the proverbial salt lick until someone that knows can answer. Using pointers from an interpreted language is not something that should work and, if it does, I expect that it will be ugly. Here is what I would do if I had no other way to do, and, at the moment, I don't. I would make an intermediary program that handles the pointers and talks to both your ruby app and the DLL in question using something simple. You did not say which language the DLL was written in, so I will assume that it is C/C++. Personally, I work with Delphi and a pascal DLL is compiled a bit differently. Also, if it is compiled for windows, they use the FAR PASCAL call to make it run faster, though Mr. Bill changed the name because he hates pascal. You can experiment to find how it all works together but it is at least something. I admit that it is ugly in the extreme, but it is a place to start if nothing more elegant gets offered. GL! -- Posted via http://www.ruby-forum.com/.