utilizing dlls in windows programming?

W

warhero

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/phidget21.dll), i've posted the
dll online. Also, here is a direct link to the C API
:http://www.phidgets.com/documentation/C_API_Manual_Phidget21.pdf

any help, hints or tips would be much appreciated.

thanks
 
P

Park Heesob

Hi,
From: "warhero" <[email protected]>
Reply-To: (e-mail address removed)
To: (e-mail address removed) (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-ruby-land
and
http://rubyforge.org/pipermail/win32utils-devel/2005-February/000294.html
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/phidget21.dll), i've posted the
dll online. Also, here is a direct link to the C API
:http://www.phidgets.com/documentation/C_API_Manual_Phidget21.pdf

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/direct/01/
 
W

warhero

Thanks, do you have previous experience with Phidgets and ruby?



Hi,
From: "warhero" <[email protected]>
Reply-To: (e-mail address removed)
To: (e-mail address removed) (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 tohttp://weblog.jamisbuck.org/2004/12/30/disappointments-in-ruby-land andhttp://rubyforge.org/pipermail/win32utils-devel/2005-February/000294....





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/phidget21.dll), i've posted the
dll online. Also, here is a direct link to the C API
:http://www.phidgets.com/documentation/C_API_Manual_Phidget21.pdf
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/direct/01/
 

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

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,073
Latest member
DarinCeden

Latest Threads

Top