Thanks for looking.

"Dennis Ranke" <exoticorn / epost.de> wrote in message
> If I'm not completely wrong, you should be able to dereference it using
> lpBuffer.unpack('P<size>') where <size> 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

Here is the program, and I am on Win XP (Home)
ruby 1.8.0 (2003-08-04) [i386-mswin32]:

#---------------------------------------------------------------------------
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 = " " * 4
ret = NetStatisticsGet.call(0,service,0,0,bufptr)

if 0 != ret
  puts "Failed:#{ret}"
  exit
end

# Here's where I'm confused...
#packstring = "I" * 13
#packstring += "L" * 27
#struct = bufptr.unpack(packstring)

STAT_WORKSTATION_SIZE =  (13*8) + (28*4)
p STAT_WORKSTATION_SIZE

struct = bufptr.unpack("P#{STAT_WORKSTATION_SIZE}")
p struct

__END__