This is a discussion on NetShareEnum problem on 98 in enumerating the shared network folders - Programmer ; I took the NetShareEnum Sample (Windows 95/98) given in MSDN. I could compile and link it withe Svrapi.lib properly. I tried to enumerate the shared folders on the same machine where the application is running. It is working fine and ...
I took the NetShareEnum Sample (Windows 95/98) given in MSDN. I could
compile and link it withe Svrapi.lib properly. I tried to enumerate
the shared folders on the same machine where the application is
running. It is working fine and giving all the shared folders. But
when I am trying to enumerate the shared folders on the remote machine
NetShareEnum is failing and giving the error code for some remote
machines as ERROR_NETWORK_ACCESS_DENIED and for some network machines
error code as ERROR_NOT_SUPPORTED. Where as the machines that I tried
were accessible to me from the windows standard explorer.
Could any one help me out what could be the reason for this?
Thanks in advance...
Sample given in MSDN is as follows
const short MAX_ENTRIES = 20;
int main(int argc, char FAR * argv)
char FAR * pszServerName = NULL;
short nLevel = 50;
struct share_info_50* pBuf = NULL;
struct share_info_50* pTmpBuf = NULL;
short nEntriesRead = 0;
short nTotalEntries = 0;
short nTotalCount = 0;
// ServerName can be NULL to indicate the local computer.
if (argc > 2)
printf("Usage: %s [\\\\ServerName]\n", argv);
if (argc == 2)
pszServerName = argv;
// Allocate the memory required to receive a maximum of
// 20 share_info_50 structures.
cbBuffer = MAX_ENTRIES * sizeof(struct share_info_50);
pBuf = malloc(cbBuffer);
if (pBuf == NULL)
// Call the NetShareEnum function to list the
// shares, specifying information level 50.
nStatus = NetShareEnum(pszServerName,
(char FAR *)pBuf,
// Loop through the entries; process errors.
if ((nStatus == NERR_Success) || (nStatus == ERROR_MORE_DATA))
if ((pTmpBuf = pBuf) != NULL)
for (i = 0; (i < nEntriesRead); i++)
assert(pTmpBuf != NULL);
if (pTmpBuf == NULL)
fprintf(stderr, "An access violation has occurred\n");
// Display the information for each entry retrieved.
printf("\n\tShare: %s\n", pTmpBuf->shi50_netname);
printf("\tPath: %s\n", pTmpBuf->shi50_path);
fprintf(stderr, "A system error has occurred: %d\n", nStatus);
// Display a warning if the buffer was not large enough
// to contain all available entries.
if ((nEntriesRead < nTotalEntries) || (nStatus == ERROR_MORE_DATA))
fprintf(stderr, "Not all entries have been enumerated\n");
// Free the allocated memory.
if (pBuf != NULL)
fprintf(stderr, "\nTotal of %d entries enumerated\n", nTotalCount);