Solved

Sharing drive

Posted on 1998-12-27
3
150 Views
Last Modified: 2010-04-02
How do I force Windows 95 to share a particular directory ? Is there any specific API to do this ?
0
Comment
Question by:kctan100
[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 6

Accepted Solution

by:
stsanz earned 20 total points
ID: 1181104
Use NetShareAdd API.
Do you want some code sample ?
0
 

Author Comment

by:kctan100
ID: 1181105
Yes, can I have the sample ?
0
 
LVL 6

Expert Comment

by:stsanz
ID: 1181106
#include  <windows.h>
#include  <svrapi.h>

void  main ()
{
struct share_info_50  si ;
NET_API_STATUS  NetResult ;

lstrcpy(si.shi50_netname,"RESOURCE") ;  // Name for the shared resource
si.shi50_type = STYPE_DISKTREE ;  // Disk resource
si.shi50_flags = SHI50F_FULL | SHI50F_PERSIST ;      
// a combination of the following flags :
// SHI50F_RDONLY  Read-only resource
// SHI50F_FULL  Full access resource
// SHI50F_PERSIST  The share persists between system startups
// SHI50F_SYSTEM  The share is not normally visible
si.shi50_remark = "Commentary" ;  // Commentary for the shared resource
si.shi50_path = "C:\\WINDOWS" ;  // Path to share
lstrcpy(si.shi50_rw_password,"rwpwd") ;  // Password for read/write access (set to "" for no password)
lstrcpy(si.shi50_ro_password,"rpwd") ;  // Password for read-only access (set to "" for no password)

// Be careful that shi50_netname, shi50_rw_password and shi50_ro_password fields are string buffers,
// while shi50_remark and shi50_path fields are string pointers.
// For more info, see svrapi.h

NetResult = NetShareAdd(NULL,50,(char*)&si,sizeof (struct share_info_50)) ;
if (NetResult != NERR_Success)
  {
  // Share creation error
  }

// Link with svrapi.lib
}

0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

691 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