Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > JRuby and JNA

Reply
Thread Tools

JRuby and JNA

 
 
Curator1
Guest
Posts: n/a
 
      04-01-2010
Ok folks, help out a noob. What am I doing wrong on the
SystemParameterInfoA call for switching the desktop - Windows7, JRuby
1.4. I'm pretty sure I got the signature right, no blowup, no error,
just no action as well. My kernel32 call works fine, so JNA is
properly there. Code followed by output. Any help greatly
appreciated!

import com.sun.jna.ptr.LongByReference
import com.sun.jna.ptr.IntByReference
Kernel32 = com.sun.jna.NativeLibrary.getInstance('kernel32')
GetDiskFreeSpace = Kernel32.getFunction('GetDiskFreeSpaceExA')
avail = LongByReference.new
total = LongByReference.new
total_free = LongByReference.new
num = GetDiskFreeSpace.invokeInt(["S:\\", avail, total,
total_free].to_java)
puts "available: #{avail.value}"
puts "total: #{total.value}"
puts "total_free #{total_free.value}"
puts "Everything fine upto here"
begin
User32=com.sun.jna.NativeLibrary.getInstance('user 32')
SysP=User32.getFunction('SystemParametersInfoA')
thirdarg=true
changedesktop=LongByReference.new(20)
puts changedesktop
zero=IntByReference.new(0)
puts zero
changenow=LongByReference.new(2)
puts changenow
s2=java.lang.String[1].new()
s2[0]=java.lang.String.new("c:\\22_bikini.bmp")
s=com.sun.jna.StringArray.new(s2)
puts SysP.invokeInt([changedesktop,zero,s,changenow].to_java)
rescue => err
puts err
end

****OUTPUT BEGINS***
available: 255961772032
total: 1000202240000
total_free 255961772032
Everything fine upto here
com.sun.jna.ptr.LongByReference@7d9f68
com.sun.jna.ptr.IntByReference@7d9f78
com.sun.jna.ptr.LongByReference@7d9f88
-1073741822 <---- is returned by SystemParametersInfoA
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: JNA performance Knute Johnson Java 6 05-09-2011 08:09 PM
Re: JNA performance Lew Java 3 05-09-2011 01:34 PM
O/T: Tag lines, or sigs (Was: JNA performance) Lew Java 7 05-09-2011 12:36 PM
JRubyHub.com: The hub to all JRuby and JRuby on Rails (JRoR)resources... sbaltagi@gmail.com Ruby 0 12-15-2007 07:28 PM
JRubyHub.com: The hub to all JRuby and JRuby on Rails (JRoR)resources... Slim Baltagi Java 0 12-15-2007 07:26 PM



Advertisments