win32net NetServerEnum BufferSize, Resume

DaveMoore djmoore at uh.edu
Sun Jan 28 21:52:50 EST 2001


On Fri, 26 Jan 2001 21:20:39 -0600, DaveMoore <djmoore at uh.edu>
(that would be me) asked four questions. I kept looking, and came
up with three answers:

[snip  Win32 API NetServerEnum under ActivePython 2.02 background
info.]
>
>The parameter prefLen, used by most of the enumeration functions,
>specifies the size of the returned data buffer, which is copied to 
>a list of dictionaries. The suggested size is 4096.
[snip]
>LMCons.h defines MAX_PREFERRED_LENGTH as ((DWORD) -1), which I take to
>mean one less than the maximum possible value (I am not a C coder).
Got this one; this means, of course, that MAX_PREFERRED_LENGTH is set
to a value of -1, but cast as a DWORD.
[snip]
>On the gripping hand, prefLen=-1 yields the entire list.
[snip]
>Does preflen=-1 result in a buffer of exactly the right size, or the
>largest buffer that can be allocated?
"Exactly the right size," correct? So why is 4096 the default?
>
>NetServerEnum also returns resumeHandle, which supposedly allows you
>to recall the function if there is more information. I'd think an
>undersized buffer would be exactly what resumeHandle would cover, but
>all my calls return zero. When, exactly, does the resume mechanism
>kick in?
>From <http://www.pythonpros.com>: "For some strange reason the code
was setting the resume handle to zero!"

So it looks like this is an error which will go away in the next
release, I hope.
>The code fragment below is based on John Nielson's NetWkstaUserEnum
>example in the Win32 Extensions Network Overview. I've deleted
>Nielson's initial call to Net...Enum, and just set resumeHandle
>nonzero so as to go through the While loop at least once. Would this
>be a problem if I did indeed need to resume?
I still don't get this one. Why two calls, one outside the loop and
one in?
[snip code]

-- 
Dave Moore == djmoore at uh.edu == I speak for me.



More information about the Python-list mailing list