@@ -49,6 +49,8 @@ static void OutputW(const wchar_t *, ...);
49
49
50
50
static int otimestamp = 0 ;
51
51
static int overbose = 0 ;
52
+ static int onetconnected = 1 ;
53
+
52
54
static int ovolumeinfo = 0 ;
53
55
static int odrivetype = 0 ;
54
56
static int oattributes = 0 ;
@@ -78,6 +80,11 @@ main(int argc, char *argv[])
78
80
} else if ((val = IsOption (option , "--verbose" )) != NULL ) {
79
81
overbose = 1 ;
80
82
83
+ } else if ((val = IsOption (option , "--netconnected" )) != NULL ) {
84
+ onetconnected = 1 ;
85
+ } else if ((val = IsOption (option , "--netremembered" )) != NULL ) {
86
+ onetconnected = 0 ;
87
+
81
88
} else if ((val = IsOption (option , "--volumeinfo" )) != NULL ) {
82
89
ovolumeinfo = 1 ;
83
90
} else if ((val = IsOption (option , "--drivetype" )) != NULL ) {
@@ -285,14 +292,18 @@ static void NetworkDisplayStruct(unsigned i, LPNETRESOURCEW lpnrLocal);
285
292
static BOOL WINAPI
286
293
EnumNetworkFunc (LPNETRESOURCEW lpnr )
287
294
{
295
+ const DWORD dwScope = (onetconnected ? RESOURCE_CONNECTED : RESOURCE_REMEMBERED );
296
+ // CONNECTED - Open connections.
297
+ // REMEMBERED - PERSISTED, aka are connected at log-on.
298
+
288
299
DWORD cbBuffer = 16384 ; // buffer size
289
300
DWORD dwResult , dwResultEnum ;
290
301
DWORD cEntries = (DWORD )- 1 ; // enumerate all possible entries
291
302
LPNETRESOURCEW lpnrLocal = NULL ; // pointer to enumerated structures
292
303
HANDLE hEnum = NULL ;
293
304
294
305
// Enumerate all currently connected resources.
295
- dwResult = WNetOpenEnumW (RESOURCE_CONNECTED , RESOURCETYPE_DISK , 0 , lpnr , & hEnum );
306
+ dwResult = WNetOpenEnumW (dwScope , RESOURCETYPE_DISK , 0 , lpnr , & hEnum );
296
307
if (dwResult != NO_ERROR ) {
297
308
OutputA ("WnetOpenEnum: failure %u\n" , (unsigned )dwResult );
298
309
return FALSE;
@@ -679,21 +690,23 @@ Usage(void)
679
690
" Query disk information using on the following operations:\n" \
680
691
"\n" \
681
692
"Operations:\n" \
682
- " volumes - iterate by volume enumeration.\n" \
683
- " network - iterate by network enumeration.\n" \
684
- " drives - iterate published drive letters.\n" \
685
- " all - all available methods.\n" \
693
+ " volumes - Iterate by volume enumeration.\n" \
694
+ " network - Iterate by network enumeration.\n" \
695
+ " drives - Iterate published drive letters.\n" \
696
+ " all - All available methods.\n" \
686
697
"\n" \
687
698
"Attributes:\n" \
688
- " --volumeinfo Volume information.\n" \
689
- " --drivetype Drive type.\n" \
690
- " --attributes Attributes.\n" \
691
- " --freespace Free space.\n" \
692
- " --statfs statfs, all attributes.\n" \
699
+ " --volumeinfo Volume information.\n" \
700
+ " --drivetype Drive type.\n" \
701
+ " --attributes Attributes.\n" \
702
+ " --freespace Free space.\n" \
703
+ " --statfs statfs, all attributes.\n" \
693
704
"\n" \
694
705
"Options:\n" \
695
- " --time Access timestamps.\n" \
696
- " --verbose Additional info.\n" \
706
+ " --time Access timestamps.\n" \
707
+ " --verbose Additional info.\n" \
708
+ " --netconnected Network status (default: connected).\n" \
709
+ " or --netremembered.\n" \
697
710
" --help\n" \
698
711
"\n" );
699
712
}
@@ -733,4 +746,3 @@ OutputW(const wchar_t *fmt, ...)
733
746
}
734
747
735
748
//end
736
-
0 commit comments