Solved

How can I write a program to emulate NET SHARE?

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Using an Atomic update intermittently results in duplicates 14 35
Need to create an object factory 2 49
Visual Studio 2015 locks debug executable 9 238
Problem to file 3 91
This article shows a few slightly more advanced techniques for Windows 7 gadget programming, including how to save and restore user settings for your gadget and how to populate the "details" panel that is displayed in the Windows 7 gadget gallery.  …
In this article, I will show how to use the Ribbon IDs Tool Window to assign the built-in Office icons to a ribbon button.  This tool will help us to find the OfficeImageId that corresponds to our desired built-in Office icon. The tool is part of…
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…

680 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