From: Dennis Ranke Date: 2004-01-11T03:36:40+09:00 Subject: Re: dereferencing pointers in Win32 API On Sat, 10 Jan 2004 11:26:59 -0600, Shashank Date wrote: > When I call this in Ruby, I do the following: > #---------------- > > netStatisticsGet = > Win32API.new('netapi32','NetStatisticsGet','PPNNP','I') > > lpBuffer = ' ' * 4 # area to store the pointer value > > # assume that the variable 'service' contains "LanmanWorkstation" in > Unicode > ret = netStatisticsGet.call(0,service,0,0,lpBuffer) > > #----------------- > > This call succeeds (because I get ret == 0) which means lpBuffer now > points > to the > buffer in memory. My questions is how do I de-reference this variable in > Ruby? If I'm not completely wrong, you should be able to dereference it using lpBuffer.unpack('P') where is the size of the buffer in bytes. Just remember that unpack returns an array, the first element of which will be the dereferenced buffer as a string. -- Dennis Ranke