CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2012

    Post NetShareEnum (..) Winapi Not Able To Remove Unnecessary Sharefolders

    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 "cc_views"(used for clearcase) and "Users" 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))
    // 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

  2. #2
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012

    Re: NetShareEnum (..) Winapi Not Able To Remove Unnecessary Sharefolders

    Please don't post the same question to multiple forums. This has been answered in the Visual c++ forum.
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++17 Compiler: Microsoft VS2017 (15.7.4)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.