Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
utilizing dlls in windows programming?
warhero
12/4/2006 5:50:00 AM
This is a two part question:
I have been reading the pick-axe book and was reading the chapter on
ruby and windows. I was reading documentation on the DL library. (is
library the correct term for that?), but my question: what is the
difference in the Win32API and using say DL.dlopen? Also in reading the
documentation on the Win32API in the back of the book, it said that
Win32API is more than likely going to be phased out.
My second question:
I am trying to utilize a DLL that is for phidgets (phidgets.com). They
have a dll (phidget21.dll) that is supposed to be used to gain access
to controlling their hardware. I've looked at their documentation for
the C language. Is that usually what a dll is written in? C? You can
download what I am looking at from the documentation section. (The C
API Manual ). I've tried a couple of different ways to try and use the
dll. Nothing as succeeded. I've tried the Win32API and the DL.dlopen.
It's probably just the way i'm trying to use it. here is what im
trying:
require "dl"
Phidget21 = DL.dlopen("phidget21");
f = Phidget21["CPhidgetRFID_create", "S"]
handle = f.call()
open = Phidget21["CPhidget_open", "II"]
open.call( 25807 )
The first problem is that handle = nil. Besides that, I don't
understand fully how to be passing back and forth parameters to the
dlls. This example cause the interactive ruby to crash (terminates in
an unusual way). I know this isn't all that's needed to work with the
phidgets, but i'm just trying to go step by step and even get it setup
correctly.
download the phidget21.dll
(
http://www.smithaaronlee.net/downloads/phi...
), i've posted the
dll online. Also, here is a direct link to the C API
:
http://www.phidgets.com/documentation/C_API_Manual_Phi...
any help, hints or tips would be much appreciated.
thanks
2 Answers
Park Heesob
12/4/2006 10:01:00 AM
0
Hi,
>From: "warhero" <beingthexemplarylists@gmail.com>
>Reply-To: ruby-talk@ruby-lang.org
>To: ruby-talk@ruby-lang.org (ruby-talk ML)
>Subject: utilizing dlls in windows programming?
>Date: Mon, 4 Dec 2006 14:55:07 +0900
>
>This is a two part question:
>
>I have been reading the pick-axe book and was reading the chapter on
>ruby and windows. I was reading documentation on the DL library. (is
>library the correct term for that?), but my question: what is the
>difference in the Win32API and using say DL.dlopen? Also in reading the
>documentation on the Win32API in the back of the book, it said that
>Win32API is more than likely going to be phased out.
>
Refer to
http://weblog.jamisbuck.org/2004/12/30/disappointments-in...
and
http://rubyforge.org/pipermail/win32utils-devel/2005-February/0...
>
>My second question:
>
>I am trying to utilize a DLL that is for phidgets (phidgets.com). They
>have a dll (phidget21.dll) that is supposed to be used to gain access
>to controlling their hardware. I've looked at their documentation for
>the C language. Is that usually what a dll is written in? C? You can
>download what I am looking at from the documentation section. (The C
>API Manual ). I've tried a couple of different ways to try and use the
>dll. Nothing as succeeded. I've tried the Win32API and the DL.dlopen.
>It's probably just the way i'm trying to use it. here is what im
>trying:
>
>require "dl"
>Phidget21 = DL.dlopen("phidget21");
>f = Phidget21["CPhidgetRFID_create", "S"]
>handle = f.call()
>open = Phidget21["CPhidget_open", "II"]
>open.call( 25807 )
>
>The first problem is that handle = nil. Besides that, I don't
>understand fully how to be passing back and forth parameters to the
>dlls. This example cause the interactive ruby to crash (terminates in
>an unusual way). I know this isn't all that's needed to work with the
>phidgets, but i'm just trying to go step by step and even get it setup
>correctly.
>
>download the phidget21.dll
>(
http://www.smithaaronlee.net/downloads/phi...
), i've posted the
>dll online. Also, here is a direct link to the C API
>:
http://www.phidgets.com/documentation/C_API_Manual_Phi...
>
>any help, hints or tips would be much appreciated.
>
The following code will work for you:
require 'dl'
Phidget21 = DL.dlopen('phidget21')
CPhidgetRFID_create = Phidget21['CPhidgetRFID_create', 'LP']
handleptr = [0].pack('L').to_ptr
CPhidgetRFID_create.call(handleptr)
handle = handleptr.to_i
CPhidget_open = Phidget21['CPhidget_open', 'ILI']
CPhidget_open.call( handle,-1 )
Or
require 'Win32API'
CPhidgetRFID_create =
Win32API.new('phidget21.dll','CPhidgetRFID_create','P','I')
CPhidget_open = Win32API.new('phidget21.dll','CPhidget_open','LI','I')
handleptr = [0].pack('L')
CPhidgetRFID_create.call(handleptr)
handle = handleptr.unpack('L')[0]
CPhidget_open.call(handle,-1)
Regards,
Park Heesob
_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today it's FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/...
warhero
12/4/2006 7:56:00 PM
0
Thanks, do you have previous experience with Phidgets and ruby?
On Dec 4, 5:00 am, "Park Heesob" <phasi...@hotmail.com> wrote:
> Hi,
>
> >From: "warhero" <beingthexemplaryli...@gmail.com>
> >Reply-To: ruby-t...@ruby-lang.org
> >To: ruby-t...@ruby-lang.org (ruby-talk ML)
> >Subject: utilizing dlls in windows programming?
> >Date: Mon, 4 Dec 2006 14:55:07 +0900
>
> >This is a two part question:
>
> >I have been reading the pick-axe book and was reading the chapter on
> >ruby and windows. I was reading documentation on the DL library. (is
> >library the correct term for that?), but my question: what is the
> >difference in the Win32API and using say DL.dlopen? Also in reading the
> >documentation on the Win32API in the back of the book, it said that
> >Win32API is more than likely going to be phased out.Refer to
http://weblog.jamisbuck.org/2004/12/30/disappointments-in...
> and
http://rubyforge.org/pipermail/win32utils-devel/2005-Febru...
....
>
>
>
>
>
> >My second question:
>
> >I am trying to utilize a DLL that is for phidgets (phidgets.com). They
> >have a dll (phidget21.dll) that is supposed to be used to gain access
> >to controlling their hardware. I've looked at their documentation for
> >the C language. Is that usually what a dll is written in? C? You can
> >download what I am looking at from the documentation section. (The C
> >API Manual ). I've tried a couple of different ways to try and use the
> >dll. Nothing as succeeded. I've tried the Win32API and the DL.dlopen.
> >It's probably just the way i'm trying to use it. here is what im
> >trying:
>
> >require "dl"
> >Phidget21 = DL.dlopen("phidget21");
> >f = Phidget21["CPhidgetRFID_create", "S"]
> >handle = f.call()
> >open = Phidget21["CPhidget_open", "II"]
> >open.call( 25807 )
>
> >The first problem is that handle = nil. Besides that, I don't
> >understand fully how to be passing back and forth parameters to the
> >dlls. This example cause the interactive ruby to crash (terminates in
> >an unusual way). I know this isn't all that's needed to work with the
> >phidgets, but i'm just trying to go step by step and even get it setup
> >correctly.
>
> >download the phidget21.dll
> >(
http://www.smithaaronlee.net/downloads/phi...
), i've posted the
> >dll online. Also, here is a direct link to the C API
> >:
http://www.phidgets.com/documentation/C_API_Manual_Phi...
>
> >any help, hints or tips would be much appreciated.The following code will work for you:
>
> require 'dl'
> Phidget21 = DL.dlopen('phidget21')
> CPhidgetRFID_create = Phidget21['CPhidgetRFID_create', 'LP']
> handleptr = [0].pack('L').to_ptr
> CPhidgetRFID_create.call(handleptr)
> handle = handleptr.to_i
> CPhidget_open = Phidget21['CPhidget_open', 'ILI']
> CPhidget_open.call( handle,-1 )
>
> Or
>
> require 'Win32API'
> CPhidgetRFID_create =
> Win32API.new('phidget21.dll','CPhidgetRFID_create','P','I')
> CPhidget_open = Win32API.new('phidget21.dll','CPhidget_open','LI','I')
> handleptr = [0].pack('L')
> CPhidgetRFID_create.call(handleptr)
> handle = handleptr.unpack('L')[0]
> CPhidget_open.call(handle,-1)
>
> Regards,
>
> Park Heesob
>
> _________________________________________________________________
> Express yourself instantly with MSN Messenger! Download today it's FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/...
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
utilizing dlls in windows programming?
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password