From: jeepcreep Date: 2004-01-11T02:44:48+09:00 Subject: Please unsubscribe --0-1942598148-1073756686=:5251 Content-Type: text/plain; charset=us-ascii Please unsubscribe Shashank Date wrote:Ruby/Win Gurus, I haven't figured out how to dereference pointers passed in as arguments to Win32 API. For example, in the following call (in C) to NetStatisticsGet API (which may be broken on NT, but that is not the point here). LPBYTE lpBuffer; int ret; ret = NetStatisticsGet ( NULL, (char *)is_workstation ? L"LanmanWorkstation" : L"LanmanServer"), 0, 0, &lpBuffer); The last parameter lpBuffer is a pointer to a pointer. The API call internally allocates memory and sets the value of the pointer to the variable whose pointer you have passed in. It is your responsibility to free the memory using NetApiBufferFree function. 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? TIA, -- shanko --0-1942598148-1073756686=:5251--