?
Solved

Sharing drive

Posted on 1998-12-27
3
Medium Priority
?
151 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 60 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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
Suggested Courses

765 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