Solved

How can I write a program to emulate NET SHARE?

Posted on 1998-04-17
3
231 Views
Last Modified: 2013-12-03
The Windows NT NET SHARE command displays a list of shares on the current system including the admin shares (C$, etc).  How can I get those values from a program (other than parsing the output of NET SHARE)?  I know about WNetOpenEnum and the related routines but I can't find a way to get the admin shares from that interface.  I don't care about getting the information remotely, it is acceptable to be on a machine to run the code.

Sample code would be nice, but just pointers to the routine names would be useful.
0
Comment
Question by:bjherbison
  • 2
3 Comments
 
LVL 11

Accepted Solution

by:
alexo earned 200 total points
ID: 1298487
You have two approaches: NetShareEnum(), which is problematic to use because the implementation differs between Win95 and NT (Use NULL as the server name to enumerate shares on the local computer); or WNetEnumResource(), which wont enumerate hidden or administrative shares.

Relevant references and code examples:
  http://www.erols.com/aaronmar/CodeSamples/WNetEnum.cpp
  http://search.dejanews.com/getdoc.xp?AN=252461577
  http://search.dejanews.com/getdoc.xp?AN=241578331
  http://search.dejanews.com/getdoc.xp?AN=295561450
  http://search.dejanews.com/getdoc.xp?AN=167648720
  http://search.dejanews.com/getdoc.xp?AN=273167908
  http://search.dejanews.com/getdoc.xp?AN=230435470
  http://search.dejanews.com/getdoc.xp?AN=242744504

The freeware WFC library has a class to do what you want:
  http://ourworld.compuserve.com/homepages/sam_blackburn/CNetShar.htm
Download the library from:
  http://ourworld.compuserve.com/homepages/sam_blackburn/wfc.zip
0
 

Author Comment

by:bjherbison
ID: 1298488
As I mentioned, WNetOpenEnum isn't useful since it doesn't get the admin shares so most of the pointers were useless.  The last pointer was helpful as it gave me a working code using NetShareEnum.
0
 
LVL 11

Expert Comment

by:alexo
ID: 1298489
One tries...
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article describes a technique for converting RTF (Rich Text Format) data to HTML and provides C++ source that does it all in just a few lines of code. Although RTF is coming to be considered a "legacy" format, it is still in common use... po…
For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now