Solved

Sharing drive

Posted on 1998-12-27
3
145 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
  • 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

895 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