如何与Windows上的其他计算机共享Windows应用程序创建的文件夹,以及如何使网络上的其他计算机在代码级别更改文件夹中的文件. [英] How do I share folders that my windows application create with other computers on the network and also make it possible for other computers on the network to alter files in the folder at code level.

查看:104
本文介绍了如何与Windows上的其他计算机共享Windows应用程序创建的文件夹,以及如何使网络上的其他计算机在代码级别更改文件夹中的文件.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一个例程,通过该例程,我的Windows应用程序可以与网络上的其他计算机共享我的Windows应用程序创建的文件夹,还可以使网络上的其他计算机更改该文件夹中的文件.我知道通过右键单击一个文件夹然后单击共享和安全性",即可手动共享一个文件夹并使文件可编辑.我想知道的是,我可以使用我的应用程序创建的代码而不是手动创建的代码来完成此操作吗?

I need a routine with which I can share folders that my windows application create with other computers on the network and also make it possible for other computers on the network to alter files in the folder.I know that by right clicking a folder and clicking sharing and security one can manually share a folder and make the files editable. What I want to know is can I get this done by using codes ones my application creates the folder rather than manually?

推荐答案

看看 ^ ]


NetShareAdd
NetShareAdd函数共享服务器资源.

安全要求
只有Administrators或Account Operators本地组的成员,或者具有Communication,Print或Server操作员组成员身份的成员才能成功执行NetShareAdd.打印操作员只能添加打印机队列.通信操作员只能添加通信设备队列.

NET_API_STATUS NetShareAdd(
LPWSTR服务器名称,
DWORD级别,
LPBYTE buf,
LPDWORD parm_err
);

参数
服务器名称
指向Unicode字符串的指针,该字符串包含要在其上执行该功能的远程服务器的名称. NULL指针或字符串指定本地计算机.
级别
指定以下值之一来设置提供的信息级别.值含义
2 buf参数指向SHARE_INFO_2结构的数组.
502 buf参数指向SHARE_INFO_502结构的数组.


buf
指向缓冲区的指针,该缓冲区中存储了带有level参数的数据集.
parm_err
指向DWORD的可选指针,该DWORD包含导致ERROR_INVALID_PARAMETER的第一个参数的索引.如果为NULL,则不会在错误时返回该参数.
返回值
如果该函数返回帐户信息,则返回值为NERR_Success.

如果函数失败,则返回值为以下错误代码之一.

值含义
ERROR_ACCESS_DENIED用户无权访问所请求的信息.
ERROR_INVALID_LEVEL为Level参数指定的值无效.
ERROR_INVALID_NAME字符或文件系统名称无效.
ERROR_INVALID_PARAMETER指定的参数无效.
NERR_DuplicateShare共享名已在此服务器上使用.
NERR_RedirectedPath该操作对重定向的资源无效.指定的设备名称已分配给共享资源.
NERR_UnknownDevDir设备或目录不存在.


QuickInfo
Windows NT:需要版本3.1或更高版本.
Windows:需要Windows 95或更高版本.
Windows CE:不支持.
标头:在lmshare.h中声明.
导入库:使用netapi32.lib(Windows NT)或svrapi.lib(Windows 95).

另请参见
网络(网络)概述,网络功能,NetShareDel
from MSDN:
NetShareAdd
The NetShareAdd function shares a server resource.

Security Requirements
Only members of the Administrators or Account Operators local group or those with Communication, Print, or Server operator group membership can successfully execute NetShareAdd. The Print operator can add only Printer queues. The Communication operator can add only communication-device queues.

NET_API_STATUS NetShareAdd(
LPWSTR servername,
DWORD level,
LPBYTE buf,
LPDWORD parm_err
);

Parameters
servername
Pointer to a Unicode string containing the name of the remote server on which the function is to execute. A NULL pointer or string specifies the local computer.
level
Specifies one of the following values to set the level of information provided. Value Meaning
2 The buf parameter points to an array of SHARE_INFO_2 structures.
502 The buf parameter points to an array of SHARE_INFO_502 structures.


buf
Pointer to the buffer in which the data set with the level parameter is stored.
parm_err
Optional pointer to a DWORD that contains the index of the first parameter that causes ERROR_INVALID_PARAMETER. If NULL, the parameter is not returned on error.
Return Values
If the function returns account information, the return value is NERR_Success.

If the function fails, the return value is one of the following error codes.

Value Meaning
ERROR_ACCESS_DENIED The user does not have access to the requested information.
ERROR_INVALID_LEVEL The value specified for the Level parameter is invalid.
ERROR_INVALID_NAME The character or file system name is invalid.
ERROR_INVALID_PARAMETER The specified parameter is invalid.
NERR_DuplicateShare The sharename is already in use on this server.
NERR_RedirectedPath The operation is invalid for a redirected resource. The specified device name is assigned to a shared resource.
NERR_UnknownDevDir The device or directory does not exist.


QuickInfo
Windows NT: Requires version 3.1 or later.
Windows: Requires Windows 95 or later.
Windows CE: Unsupported.
Header: Declared in lmshare.h.
Import Library: Use netapi32.lib (Windows NT) or svrapi.lib (Windows 95).

See Also
Networking (Net) Overview, Net Functions, NetShareDel


这篇关于如何与Windows上的其他计算机共享Windows应用程序创建的文件夹,以及如何使网络上的其他计算机在代码级别更改文件夹中的文件.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆