Today’s Little Program obtains the comment string for a share. This is what shows up in the net view output like this:
C:\>>net view \\scratch Shared resources at \\scratch Share name Type Used as Comment ------------------------------------------------------------------------------- temp Disk MAY BE DELETED AT ANY TIME WITHOUT WARNING The command completed successfully.
Here goes. Remember: Little Programs do little to no error checking.
#define UNICODE
#define _UNICODE
#include <windows.h>
#include <lm.h>
#include <stdio.h>
int __cdecl wmain(int argc, wchar_t **argv)
{
PSHARE_INFO_1 info1;
NetShareGetInfo(argv[1], argv[2], 1, (LPBYTE*)&info1);
printf("name = %ls\n", info1->shi1_netname);
printf("remark = %ls\n", info1->shi1_remark);
NetApiBufferFree(info1);
return 0;
}
The expected command line arguments are the server name and the share name. We ask for information level 1, which gives us the name, the type, and the remark. I just print the name and the remark.
Bonus program:
#define UNICODE
#define _UNICODE
#include <windows.h>
#include <lm.h>
#include <stdio.h>
int __cdecl wmain(int argc, wchar_t **argv)
{
PSERVER_INFO_101 info101;
NetServerGetInfo(argv[1], 101, (LPBYTE*)&info101);
printf("comment = %ls\n", info101->sv101_comment);
NetApiBufferFree(info101);
return 0;
}
This program prints the server comment.
0 comments