home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 July / CHIP_CD_2004-07.iso / software / nncron_hit / files / nncron189.exe / plugins / net.spf < prev    next >
Text File  |  2003-06-26  |  1KB  |  52 lines

  1. \ File:         net.spf
  2. \ Author:       Nicholas Nemtsev
  3. \ Date:         22.01.2002
  4. \ Description:  Useful network words
  5.  
  6. \ For Win NT/2k/XP only
  7.  
  8. \ %SESSIONSCOUNT%       - number of sessions
  9. \ %LOGGEDUSERCOUNT%     - number of logged on users
  10. \ %SESSIONSERVERS%      - list of servers separated by space
  11. \ %SESSIONSUSERS%       - list of users separated by space
  12.  
  13. WINAPI: NetWkstaUserEnum NETAPI32.DLL
  14. WINAPI: NetSessionEnum NETAPI32.DLL
  15. WINAPI: NetApiBufferFree NETAPI32.DLL
  16.  
  17. : SessionEnum { \ buf entriesread totalentries resume_handle -- adr cnt }
  18.     AT resume_handle AT totalentries AT entriesread
  19.     10240 AT buf 1 0 0 0 NetSessionEnum DROP 
  20.     buf entriesread ;
  21.  
  22. : SESSIONSCOUNT 
  23.     SessionEnum 0 ROT ROT 
  24.     0 ?DO DUP I 6 CELLS * + CELL+ @ C@ IF SWAP 1+ SWAP THEN LOOP 
  25.     NetApiBufferFree DROP ;
  26.  
  27. : LOGGEDUSERCOUNT { \ entriesread totalentries resumehandle -- count }
  28.     0 TO resumehandle
  29.     AT resumehandle  AT totalentries  AT entriesread 
  30.     16 PAD 0 0 NetWkstaUserEnum DROP
  31.     totalentries
  32. ;
  33.  
  34. : SessionsAll { offs -- a u }
  35.     PAD 0!
  36.     SessionEnum 
  37.     0 ?DO DUP I 6 CELLS * + offs + @ DUP C@
  38.           IF
  39.               BEGIN DUP C@ ?DUP WHILE 
  40.                 SP@ 1 PAD +ZPLACE DROP 2+
  41.               REPEAT DROP
  42.               S"  "  PAD +ZPLACE
  43.           ELSE DROP THEN
  44.     LOOP
  45.     NetApiBufferFree DROP
  46.     PAD ASCIIZ>
  47. ;
  48.  
  49. : SESSIONSERVERS ( -- a u)  0 SessionsAll ;
  50.  
  51. : SESSIONSUSERS ( -- a u)  1 CELLS SessionsAll ;
  52.