Extracting shared drive information from a local or remote server

Environment: VC6 SP3, NT4 SP5

To extract shared drive information from a local or remote server (including shared and system shared drives), implement the following code into your sources.



int CNetworkAccess::EnumerateResource (LPSTR svrname)
{
	PSHARE_INFO_502 BufPtr, p;
	NET_API_STATUS res;
	DWORD er = 0, tr = 0, resume = 0;
	WCHAR serverName[36];
	int ierror = 0;

	// convert to a unicode string
	if ((ierror = MultiByteToWideChar (CP_ACP,
					   MB_PRECOMPOSED,
					   svrname,
					   -1,
					   serverName,
					   36)) == 0)
	{
		AfxMessageBox ("BAD conversion -> bugging out ... !!!");
		return STATUS_BAD;
	}

	do
	{
		// return shared drive information for the server selected
		res = NetShareEnum ((TCHAR *)serverName,
				    502,
				    (LPBYTE *)&BufPtr,
				    0xFFFFFFFF,
				    &er,
				    &tr,
				    &resume);

		// if OK
		if (res == ERROR_SUCCESS || res == ERROR_MORE_DATA)
		{
			p = BufPtr;
			for (int i = 1; i <= (int)er; i++)
			{
				// do something with the drive information
				
				// increment pointer to next drive
				p++;
			}
			// free system created memory
			NetApiBufferFree (BufPtr);
		}

	} while (res == ERROR_MORE_DATA);

	// return the status
	return STATUS_OK;
}

To extract information from the local server, pass NULL into the function

History



Comments

  • how to add share folder in remote computer(in domain)

    Posted by Legacy on 05/28/2003 12:00am

    Originally posted by: mohsen

    how to add share folder in remote computer(in domain)
    hi!
    i have a problem in my programm.
    problem is:
    i want to transfer a folder from my computer in domain to
    "program file" folder of another computer..but this folder in remote computer isnt share!
    how can i do it..please send my answer fast
    thanks a lot..

    Reply
  • how to share a folder in remote computer?(in domain)

    Posted by Legacy on 05/28/2003 12:00am

    Originally posted by: mohsen

    how to add share folder in remote computer(in domain)
    hi!
    i have a problem in my programm.
    problem is:
    i want to transfer a folder from my computer in domain to
    "program file" folder of another computer..but this folder in remote computer isnt share!
    how can i do it..please send my answer fast
    thanks a lot..

    Reply
  • Stop acting like a jerk

    Posted by Legacy on 03/07/2003 12:00am

    Originally posted by: Marc Anthony

    Put the entire code and stop wasting our time!!!!! Pisshead!!!

    Reply
  • how to acces share for linux client?

    Posted by Legacy on 11/18/2002 12:00am

    Originally posted by: sak

    but wht if the client mahcine who is to be browsed requires username password for authentication before list the shares....like here in my case im using win2k domain but there is one machine of linux who is using samba for such things...and on browsing throgh command prompt it gives me a dialog box for authenctaion.........how can i resolve that senario?

    Reply
  • Please send me the complete proyect.

    Posted by Legacy on 02/12/2002 12:00am

    Originally posted by: Salvador Sierra

    Give mi a complete source code, please.

    Reply
  • How to Find Files across entire network ??????

    Posted by Legacy on 06/04/2001 12:00am

    Originally posted by: Mandar Godbole

    Is there any tool / utility / program Code available which can find some file say xxx.exe across entire network ( i.e. All computers connected to that machine ) ????

    Please I need this information very urgently.

    If it is not available readymade What kind of programming I need to do for that ?????

    Reply
  • how to get information about DNS server and WINS server

    Posted by Legacy on 04/06/2001 12:00am

    Originally posted by: jaisingh

    I can get information about one particular workstation by using netapi32.dll.I have to collect information about
    DNS server and WINS server.
    i want to know in which dll(like winsock.dll,..) i can get
    the exported functions.


    Reply
  • How to Get Shared File Information?

    Posted by Legacy on 10/18/2000 12:00am

    Originally posted by: Shakey973

    Can someone offer some advice on how
    I can find out what user on a network
    currently has a file open (e.g., a word
    document, excel workbook, etc) ?

    I need to find out how to display info
    to my user, when they try to open a file
    that is in use. I want to inform them
    who is currently using the file.

    Is there a simple way to do this on a
    Windows NT system?

    Reply
  • Send please project release

    Posted by Legacy on 10/31/1999 12:00am

    Originally posted by: John

    Send please project release

    Reply
  • Give complete project please.

    Posted by Legacy on 10/08/1999 12:00am

    Originally posted by: BOTAN

    Give mi a complete source code, please.

    Reply
  • Loading, Please Wait ...

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Live Event Date: November 20, 2014 @ 2:00 p.m. ET / 11:00 a.m. PT Are you wanting to target two or more platforms such as iOS, Android, and/or Windows? You are not alone. 90% of enterprises today are targeting two or more platforms. Attend this eSeminar to discover how mobile app developers can rely on one IDE to create applications across platforms and approaches (web, native, and/or hybrid), saving time, money, and effort and introducing apps to market faster. You'll learn the trade-offs for gaining long …

  • Live Event Date: October 29, 2014 @ 11:00 a.m. ET / 8:00 a.m. PT Are you interested in building a cognitive application using the power of IBM Watson? Need a platform that provides speed and ease for rapidly deploying this application? Join Chris Madison, Watson Solution Architect, as he walks through the process of building a Watson powered application on IBM Bluemix. Chris will talk about the new Watson Services just released on IBM bluemix, but more importantly he will do a step by step cognitive …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds