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

  • Lenovo recommends Windows 8 Pro. "I dropped my laptop getting out of the taxi." This probably sounds familiar to most IT professionals. If your employees are traveling, you know their devices are in for a rough go. Whether it's a trip to the conference room or a convention out of town, any time equipment leaves a user's desk it is at risk of being put into harm's way. Stay connected at all times, whether at the office or on the go, with agile, durable, and flexible devices like the Lenovo® …

  • Live Event Date: September 23, 2015 @ 1:00 p.m. ET / 10:00 a.m. PT The cloud is not just about a runtime platform for your projects – now, you can do your development in the cloud, too. Check out this upcoming eseminar to learn how the cloud improves your development experience and team collaboration. Join Dana Singleterry, Principal Product Manager for Oracle Dev Tools, as he discusses how to simplify every aspect of the development lifecycle, including requirements gathering, version management, code …

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date