From: Daniel Berger Date: 2008-01-29T14:18:51+09:00 Subject: [OT] JNA Help - LPDWORD Hi all, Does anyone happen to know the JNA equivalent of [24].pack('L')? I need to pass a LPDWORD (pointer to a long) to a function. Here's the code snippet I'm trying to make work. I'm pretty sure it's failing because 'num' isn't a proper data structure. require 'java' Advapi32 = com.sun.jna.NativeLibrary.getInstance('advapi32') GetUserNameA = Advapi32.getFunction('GetUserNameA') buf = java.nio.ByteBuffer.allocate(24) num = [24].pack('L') p GetUserNameA.invokeInt([buf, num].to_java) # Fails buf = String.from_java_bytes(buf.array) p buf.strip # Empty? p num.unpack('L').first # Should be length of user Here's the equivalent win32-api script: require 'win32/api' include Win32 GetUserNameA = API.new('GetUserNameA', 'PP', 'I', 'advapi32') buf = 0.chr * 24 num = [buf.size].pack('L') p GetUserNameA.call(buf, num) p buf.strip p num.unpack('L').firs Thanks, Dan