Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!talisker.lacave.net!lacave.net!not-for-mail From: Su Zhang Newsgroups: comp.lang.ruby Subject: Re: Sharing data between ruby and a custom dll with Win32API Date: Tue, 17 May 2011 15:00:51 -0500 Organization: Service de news de lacave.net Lines: 23 Message-ID: <5da0f9c6a53ac8a2ac026645fdbafd2e@ruby-forum.com> References: <5daf6b7d2acef28191055cb217178954@ruby-forum.com> NNTP-Posting-Host: bristol.highgroove.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Trace: talisker.lacave.net 1305662477 35974 65.111.164.187 (17 May 2011 20:01:17 GMT) X-Complaints-To: abuse@lacave.net NNTP-Posting-Date: Tue, 17 May 2011 20:01:17 +0000 (UTC) In-Reply-To: <5daf6b7d2acef28191055cb217178954@ruby-forum.com> X-Received-From: This message has been automatically forwarded from the ruby-talk mailing list by a gateway at comp.lang.ruby. If it is SPAM, it did not originate at comp.lang.ruby. Please report the original sender, and not us. Thanks! For more details about this gateway, please visit: http://blog.grayproductions.net/categories/the_gateway X-Mail-Count: 383400 X-Ml-Name: ruby-talk X-Rubymirror: Yes X-Ruby-Talk: <5da0f9c6a53ac8a2ac026645fdbafd2e@ruby-forum.com> Xref: x330-a1.tempe.blueboxinc.net comp.lang.ruby:4690 Hi Futar, I suppose you are using 'p' as the return type specifier of Win32API; this is interpreted as a pointer to a null-terminated string.Therefore, any null byte in your array of floats will mark the end of the "string" buffer. In this case, I think you can simply reference the same buffer you pass to @getkaplamatrix. matrix2 = matrix.pack("f*") @getKaplaMatrix.call(index, matrix2) matrix3 = matrix2.unpack("f*") And if you really do need to return a reference to something, you will often have to return it as an integer address and manipulate (reference and dereference) it through native interfaces such as RtlMoveMemory. Su -- Posted via http://www.ruby-forum.com/.