-
Notifications
You must be signed in to change notification settings - Fork 352
/
list_remote_shares.nim
35 lines (31 loc) · 900 Bytes
/
list_remote_shares.nim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import winim
import std/parseopt
import os
var target = ""
var p = initOptParser(commandLineParams())
while true:
p.next()
case p.kind
of cmdEnd: break
of cmdArgument:
target = p.key
else:
discard
if target == "":
echo("Usage: ", getAppFilename(), " <serverName>")
quit(1)
var structSize = sizeOf(typeof(SHARE_INFO_502))
var buf: PSHARE_INFO_502
var entriesread: DWORD
entriesread = 0
var totalentries: DWORD
totalentries = 0
var resume_handle: DWORD
resume_handle = 0
var ret = NetShareEnum(target,502,cast[ptr LPBYTE](&buf), MAX_PREFERRED_LENGTH, &entriesread, &totalentries,&resume_handle)
if NT_SUCCESS(ret) == true:
var currentPtr = buf
for i in 1 .. entriesread:
echo(currentPtr.shi502_netname, " -> ", currentPtr.shi502_path)
currentPtr = cast[PSHARE_INFO_502](cast[int](currentPtr) + cast[int](structSize))
NetApiBufferFree(buf);