From: Park Heesob Date: 2004-01-11T08:37:11+09:00 Subject: Re: dereferencing pointers in Win32 API Hi, > > Thanks for looking. > > "Dennis Ranke" wrote in message > > 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. > > I tried that and i get: > > C:/atest/tst_netapi32.rb:28:in `unpack': no associated pointer > (ArgumentError) > from C:/atest/tst_netapi32.rb:28 > Just use memcpy. Try this code. require "Win32API" SERVICE_WORKSTATION = [ 76,0,97,0,110,0,109,0,97,0,110,0,87,0,111,0,114,0, 107,0,115,0,116,0,97,0,116,0,105,0,111,0,110,0,0,0] SERVICE_WORKSTATION.each{|e| print "%c" % e if e > 0} puts service = SERVICE_WORKSTATION.pack("U*") # Unicode NetStatisticsGet = Win32API.new('netapi32','NetStatisticsGet','PPNNP','I') bufptr = "\0" * 4 ret = NetStatisticsGet.call(0,service,0,0,bufptr) if 0 != ret puts "Failed:#{ret}" exit end STAT_WORKSTATION_SIZE = (13*8) + (28*4) rbuf = "\0" * STAT_WORKSTATION_SIZE memcpy = Win32API.new('msvcrt','memcpy','PPL','P') memcpy.Call(rbuf,bufptr,STAT_WORKSTATION_SIZE) struct = rbuf.unpack("L*") p struct __END__ Regards, Park Heesob