Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

How can I write a program to emulate NET SHARE?

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
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 Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

808 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