Solved

Sharing drive

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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

747 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

9 Experts available now in Live!

Get 1:1 Help Now