Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Sharing drive

Posted on 1998-12-27
3
Medium Priority
?
153 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
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 be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

618 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