Click here to Skip to main content
11,640,125 members (66,521 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: Windows C++/MFC VC++
For getting the share folder name i have been used the following code , here i am able to get the folder names . But the problem what i am facing is along with the share folder created by the user it gives some extra folder also , i don't know how to prevent the programe to hide that unnecessary folder names . Like in my case i am getting "[b]cc_views[/b]"(used for clearcase) and "[b]Users[/b]" folders , which i want to remove from my folder lists .

I wrote the following codes , Please help in getting the correct output .

#ifndef UNICODE
#define UNICODE
#include <windows.h>
#include <stdio.h>
#include <lm.h>
#pragma comment(lib, "Netapi32.lib")
#pragma comment(lib, "Advapi32.lib")
void wmain( int argc, TCHAR *lpszArgv[ ])
   PSHARE_INFO_502 BufPtr,p;
   LPTSTR   lpszServer = NULL;
   DWORD er=0,tr=0,resume=0, i;
   case 2:
      lpszServer = lpszArgv[1];
      printf("Usage: NetShareEnum <servername>\n");
   // Print a report header.
   // Call the NetShareEnum function; specify level 502.
   do // begin do
      res = NetShareEnum ((LPSTR)lpszServer, 502, (LPBYTE *) &BufPtr, MAX_PREFERRED_LENGTH, &er, &tr, &resume);
      // If the call succeeds,
      if(res == ERROR_SUCCESS || res == ERROR_MORE_DATA)
         // Loop through the entries;
         //  print retrieved data.
             LPCTSTR str = (LPCTSTR)p->shi502_remark;
             if(!(lstrcmpi(str,L"Remote admin")==0 ||lstrcmpi(str, L"Remote IPC")==0 || lstrcmpi(str,L"Default share")==0)) //Help in removing from extra folder based on the remarks
         // Free the allocated buffer.
         printf("Error: %ld\n",res);
   // Continue to call NetShareEnum while 
   //  there are more entries. 
   while (res==ERROR_MORE_DATA); // end do
Posted 12-Apr-13 17:55pm
Edited 12-Apr-13 18:00pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

i executed the same code i didnt got users folder in the enumerated list. have you expilictly shared it ??
regarding cc_views that will come since this is done by clearcase and cannot be avoided so you have to explicilty ignore these folder during enumeration. i.e comparing with

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Suvendu Shekhar Giri 225
1 F-ES Sitecore 170
2 CPallini 167
3 Sergey Alexandrovich Kryukov 144
4 himanshu agarwal 142
0 OriginalGriff 9,081
1 Sergey Alexandrovich Kryukov 8,847
2 Mika Wendelius 7,027
3 Suvendu Shekhar Giri 2,650
4 F-ES Sitecore 2,558

Advertise | Privacy | Mobile
Web04 | 2.8.150731.1 | Last Updated 13 Apr 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100