# Wierd problems with Win32API and dlls

**URL:** <https://www.ruby-forum.com/t/wierd-problems-with-win32api-and-dlls/141015>\
**Category:** Ruby\
**Created:** [June 20, 2008, 8:11pm UTC](https://www.ruby-forum.com/t/wierd-problems-with-win32api-and-dlls/141015 "2008-06-20T20:11:03Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![bigdaddy71](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bbe5ce/32.png) [@bigdaddy71](https://www.ruby-forum.com/u/bigdaddy71)\
**Post date:** [June 20, 2008, 8:11pm UTC](https://www.ruby-forum.com/t/wierd-problems-with-win32api-and-dlls/141015/1 "2008-06-20T20:11:03Z")

</div>

i am currently developing a more advanced audio and input system for the  
ruby / gosu package and ive come across a strange problem with the audio  
dll im using.  
(The dll was created by a friend for his game but given to me to allow  
me to further my system so i dont have the source code)  
I have created the audio system before on rpgmaker xp (dont laugh… its  
what got me into ruby back in the day) and was transfering it across on  
my friends windows vista… everything was good there (except it needed  
to loop the context creation process about 40 times to create it  
properly - but thats understandable and worth it as it only needs to be  
done on first startup) but when i moved the code back to my xp the  
system doesnt work anymore. I have no idea why this is happening but the  
context creation returns 0 which is a return error (it should return the  
handle to a created audio stream). If possible would someone be able to  
look at the dll (attached) and tell me what is wrong with this code:

require ‘Win32API’  
alias oldprint print  
def print(\*args)  
Win32API.new(‘User32’,‘MessageBox’,[‘i’,‘p’,‘p’,‘i’],‘i’).call(0,args.to\_s,‘test’,0)  
end  
alias p print  
begin  
loop do  
print ‘attempting to create context’  
@context =  
Win32API.new(‘MCEAudio.dll’,‘AudioContextInitialize’,[’’],‘l’).call  
if @context != 0  
break  
end  
end  
print ‘context created successfully - WIN!’  
rescue Exception =\> error  
print “an error occured but shouldn’t have - the error is: #{error}”  
end

all that happens is the context will not be created correctly and will  
try to be made again… i added my edited messaging system incase of an  
error… its much easier to read it if it doesnt close down instantly.

i hope someone can find out whats wrong as this is REALLY important…
