Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How can I write a program to emulate NET SHARE?

Posted on 1998-04-17
3
Medium Priority
?
240 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
[X]
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
  • 2
3 Comments
 
LVL 11

Accepted Solution

by:
alexo earned 600 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

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

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

This article describes how to add a user-defined command button to the Windows 7 Explorer toolbar.  In the previous article (http://www.experts-exchange.com/A_2172.html), we saw how to put the Delete button back there where it belongs.  "Delete" is …
As more and more people are shifting to the latest .Net frameworks, the windows presentation framework is gaining importance by the day. Many people are now turning to WPF controls to provide a rich user experience. I have been using WPF controls fo…
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…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

664 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