From: Shashank Date Date: 2004-07-13T23:37:58+09:00 Subject: Re: win32api: how to access NetFileEnum results? Hi Jos, --- Jos Backus wrote: > I'm trying to programmatically determine any network > opened files on a Windows 2003 Server system using > the NETAPI32.NetFileEnum API. I cannot claim to have any insight into this API, but when I ran your code "as is" I got an error: undefined local variable or method `bufptr' so I changed the script slightly > > My code looks like this: > > require "Win32API" > > MAX_PREFERRED_LENGTH = -1 > level = 3 > entriesread = "\0" * 4 > totalentries = "\0" * 4 > resume_handle = "\0" * 4 bufptr = "\0" * 4 # <<<<< added this assignment > NetFileEnum = Win32API.new("netapi32", > "NetFileEnum", 'PPPNPNPPP', 'I') > ret = > NetFileEnum.call(0,0,0,level,bufptr,MAX_PREFERRED_LENGTH,entriesread,totalentries,resume_handle) > > if 0 != ret > puts "Failed:#{ret}" > exit > end > > rbuf = "\0" * 10240 # testing, should be > *entriesread * sizeof(FILE_INFO_3) > memcpy = > Win32API.new('msvcrt','memcpy','PPL','P') > memcpy.call(rbuf,bufptr,rbuf.size) > > p rbuf > and I got a long string stuffed with some binary data. Of course, like you said, it did not match the output of: C:\>net file There are no entries in the list. C:\> I am not sure if this helps. -- shanko PS> I tried this on Win 2K Professional using ruby 1.8.2 (2004-06-04) [i386-mswin32] __________________________________ Do you Yahoo!? Yahoo! Mail - 50x more storage than other providers! http://promotions.yahoo.com/new_mail