NetShareSetInfo() Program Example
This function sets the parameters of a shared resource. If 503 is specified for the level parameter, the remote server specified in the shi503_servername member of the SHARE_INFO_503 structure must have been bound to a transport protocol using the NetServerTransportAddEx() function. In the call to NetServerTransportAddEx(), either 2 or 3 must have been specified for the level parameter, and the SVTI2_SCOPED_NAME flag must have been specified in the SERVER_TRANSPORT_INFO_2 structure for the transport protocol. The following code sample demonstrates how to set the comment associated with a shared resource using a call to the NetShareSetInfo() function. To do this, the sample specifies information level 1004 (SHARE_INFO_1004).
Create a new empty Win32 console application project. Give the project name and change the project location is needed.

Then, add the source file and give it a suitable name.

Then, add the following source code.
#include <windows.h>
#include <stdio.h>
#include <lm.h>
#pragma comment(lib, Netapi32.lib)
int wmain(int argc, WCHAR *argv[])
{
SHARE_INFO_1004 p;
NET_API_STATUS res;
DWORD parm_err = 0;
if(argc<4)
{
wprintf(LUsage: %s server share \remark\\n, argv[0]);
wprintf(LExample: %s BigdotServer mysharefolder \This shared folder contains virus!\\n, argv[0]);
}
else
{
// Fill in SHARE_INFO_1004 structure member.
p.shi1004_remark=argv[3];
// Call the NetShareSetInfo() function,
// specifying information level 1004.
res=NetShareSetInfo(argv[1], argv[2], 1004, (LPBYTE)&p, &parm_err);
// Display the result of the call.
if(res==0)
{
wprintf(LNetShareSetInfo() is OK!\n);
wprintf(LShare remark was set successfully!\n);
}
else
{
wprintf(LNetShareSetInfo() failed! Error: %u\tparmerr = %u\n, res, parm_err);
}
}
return 0;
}
We will set or change the share Comment for the shared folder.

Build and run the project. The following screenshot is a sample output.

Verify our previous action.
