如何共享文件夹????

raul2000 2001-07-26 02:05:07
如何用程序将本机文件夹共享???有函数吗??
...全文
949 3 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
swordbroken 2001-09-09
  • 打赏
  • 举报
回复
NetShareAdd函数:

#include <stdio.h>
#include <windows.h>
#include <svrapi.h>

int main(int argc, char FAR * argv[])
{
short nLevel = 50;
struct share_info_50* pBuf = NULL;
unsigned short cbBuffer;
NET_API_STATUS nStatus;

if (argc != 3)
{
printf("Usage: %s ShareName SharePath\n", argv[0]);
exit(1);
}

cbBuffer = sizeof(struct share_info_50);
pBuf = malloc(cbBuffer);

if (pBuf == NULL)
printf("No memory\n");

strcpy(pBuf->shi50_netname, argv[1]);
pBuf->shi50_type = STYPE_DISKTREE;
pBuf->shi50_flags = SHI50F_FULL;
pBuf->shi50_remark = NULL;
pBuf->shi50_path = argv[2];
pBuf->shi50_rw_password[0] = '\0'; // No password
pBuf->shi50_ro_password[0] = '\0'; // No password

nStatus = NetShareAdd(NULL,
nLevel,
(char FAR *)pBuf,
cbBuffer);

if (pBuf != NULL)
free(pBuf);

return 0;
}
heyongzhou 2001-07-26
  • 打赏
  • 举报
回复
#define UNICODE
#include <windows.h>
#include <stdio.h>
#include <lm.h>

void wmain( int argc, TCHAR *argv[ ])
{
NET_API_STATUS res;
SHARE_INFO_2 p;
DWORD parm_err = 0;

if(argc<2)
printf("Usage: NetShareAdd server\n");
else
{
//
// Fill in the SHARE_INFO_2 structure.
//
p.shi2_netname = TEXT("TESTSHARE");
p.shi2_type = STYPE_DISKTREE; // disk drive
p.shi2_remark = TEXT("TESTSHARE to test NetShareAdd");
p.shi2_permissions = 0;
p.shi2_max_uses = 4;
p.shi2_current_uses = 0;
p.shi2_path = TEXT("C:\\");
p.shi2_passwd = NULL; // no password
//
// Call the NetShareAdd function,
// specifying level 2.
//
res=NetShareAdd(argv[1], 2, (LPBYTE) &p, &parm_err);
//
// If the call succeeds, inform the user.
//
if(res==0)
printf("Share created.\n");

// Otherwise, print an error,
// and identify the parameter in error.
//
else
printf("Error: %u\tparmerr=%u\n", res, parm_err);
}
return;
}
qin_wei 2001-07-26
  • 打赏
  • 举报
回复
用Winnet系列api

16,548

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • AIGC Browser
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧