Solved

How can I write a program to emulate NET SHARE?

Posted on 1998-04-17
3
229 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

If you have ever found yourself doing a repetitive action with the mouse and keyboard, and if you have even a little programming experience, there is a good chance that you can use a text editor to whip together a sort of macro to automate the proce…
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and 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…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

746 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

12 Experts available now in Live!

Get 1:1 Help Now