Problems With DirectSound & DL

Hello Everyone,
    I'm trying to make an MP3 player in Ruby. I would like to make it in pure Ruby, but I've come to the conclusion that Ruby is too high level to mess around with sound buffers and such. So I'm making the MP3 player in Ruby, and using DL and dsound.dll to access the DirectSound API. But I'm having trouble invoking IDirectSound8::SetCooperativeLevel as mentioned on this page. I've tried every way I could think of to try to get it to run, but with no success. Below is the Ruby code that I have so far. I know its messy, and I'm planning to do a rewrite of it before I distribute it. Right now I'm just trying to learn how to accomplish invoking the DLL.

The code:

require 'dl'
require 'dl/import'
require 'pp'
hello_me = DL.malloc(DL.sizeof('P'))
hwnd = DL.malloc(DL.sizeof('P'))
dsound = DL.dlopen('dsound')
soundobject1 = dsound['DirectSoundCreate8', 'LSPS']
pp, hello_me, nil)
pp hello_me
module Blah
extend DL::Importable
def self.setCooperativeLevel(ptr, appwindow=0, priority='ii')
coopthing =
coopthing += "#{ptr.to_ptr}"
coopthing += "->SetCooperativeLevel("
 if appwindow == 0 then
coopthing += "hwnd"
coopthing += appwindow
if priority == 'ii' then
coopthing += ", DSSCL_PRIORITY)"
coopthing += ", " + priority + ")"
pp coopthing
extern "#{coopthing}"
pp Blah.setCooperativeLevel(hello_me)

I'm running Windows XP Professional.

Philip W.