{"id":91441,"date":"2015-10-05T07:00:00","date_gmt":"2015-10-05T21:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/20151005-00\/?p=91441\/"},"modified":"2019-03-13T12:20:15","modified_gmt":"2019-03-13T19:20:15","slug":"20151005-00","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20151005-00\/?p=91441","title":{"rendered":"How do I obtain the comment for a share?"},"content":{"rendered":"<p>Today&#8217;s Little Program obtains the comment string for a share. This is what shows up in the <code>net view<\/code> output like this: <\/p>\n<pre>\nC:\\&gt;&gt;net view \\\\scratch\nShared resources at \\\\scratch\n\nShare name  Type  Used as  Comment\n\n-------------------------------------------------------------------------------\ntemp        Disk           <a HREF=\"http:\/\/blogs.msdn.com\/b\/oldnewthing\/archive\/2011\/06\/07\/10171801.aspx\">MAY BE DELETED AT ANY TIME WITHOUT WARNING<\/a>\nThe command completed successfully.\n<\/pre>\n<p>Here goes. Remember: Little Programs do little to no error checking. <\/p>\n<pre>\n#define UNICODE\n#define _UNICODE\n#include &lt;windows.h&gt;\n#include &lt;lm.h&gt;\n#include &lt;stdio.h&gt;\n\nint __cdecl wmain(int argc, wchar_t **argv)\n{\n PSHARE_INFO_1 info1;\n NetShareGetInfo(argv[1], argv[2], 1, (LPBYTE*)&amp;info1);\n printf(\"name = %ls\\n\", info1-&gt;shi1_netname);\n printf(\"remark = %ls\\n\", info1-&gt;shi1_remark);\n <a HREF=\"http:\/\/blogs.msdn.com\/b\/oldnewthing\/archive\/2013\/03\/11\/10399694.aspx\">NetApiBufferFree<\/a>(info1);\n return 0;\n}\n<\/pre>\n<p>The expected command line arguments are the server name and the share name. We ask for <a HREF=\"http:\/\/msdn.microsoft.com\/en-us\/library\/windows\/desktop\/bb525407(v=vs.85).aspx\">information level 1<\/a>, which gives us the name, the type, and the remark. I just print the name and the remark. <\/p>\n<p><b>Bonus program<\/b>: <\/p>\n<pre>\n#define UNICODE\n#define _UNICODE\n#include &lt;windows.h&gt;\n#include &lt;lm.h&gt;\n#include &lt;stdio.h&gt;\n\nint __cdecl wmain(int argc, wchar_t **argv)\n{\n PSERVER_INFO_101 info101;\n NetServerGetInfo(argv[1], 101, (LPBYTE*)&amp;info101);\n printf(\"comment = %ls\\n\", info101-&gt;sv101_comment);\n NetApiBufferFree(info101);\n return 0;\n}\n<\/pre>\n<p>This program prints the <a HREF=\"http:\/\/blogs.msdn.com\/b\/oldnewthing\/archive\/2013\/07\/31\/10438199.aspx\">server comment<\/a>. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>NetShareGetInfo.<\/p>\n","protected":false},"author":1069,"featured_media":111744,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[25],"class_list":["post-91441","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-code"],"acf":[],"blog_post_summary":"<p>NetShareGetInfo.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/91441","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/users\/1069"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/comments?post=91441"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/91441\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media\/111744"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media?parent=91441"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=91441"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=91441"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}