游戏开发论坛

 找回密码
 立即注册
搜索
查看: 1063|回复: 0

如何映射网络驱动器 wxh zt

[复制链接]

1367

主题

1993

帖子

2118

积分

金牌会员

Rank: 6Rank: 6

积分
2118
发表于 2004-11-16 16:55:00 | 显示全部楼层 |阅读模式
char netpath[MAX_PATH]="\\\\Shichengming\\共享的硬盘 (H)";//ZHOU 为机器名,F为共享的文件夹名或盘符名
char drv[32]="H:";
NETRESOURCE netres;
netres.dwScope =RESOURCE_GLOBALNET;
netres.dwType =RESOURCETYPE_ANY;
netres.dwDisplayType =RESOURCEDISPLAYTYPE_GENERIC;
netres.dwUsage =RESOURCEUSAGE_CONNECTABLE;
netres.lpLocalName = drv;
netres.lpRemoteName = netpath;
netres.lpComment =NULL;
netres.lpProvider =NULL;
DWORD  rslt=WNetAddConnection2(&netres,NULL,NULL,FALSE);

if (rslt==NO_ERROR)
{
   CString str;
   str.Format ("WNetAddConnection2() return code=%d",rslt);
   MessageBox(str);
}
else
AfxMessageBox("erro");
断开网络驱动器
char drv[256]="H:";

DWORD  rslt=WNetCancelConnection2(  drv,0,FALSE);
CString str;
str.Format ("WNetCancelConnection2() return code=%d",rslt);
MessageBox(str);
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

作品发布|文章投稿|广告合作|关于本站|游戏开发论坛 ( 闽ICP备17032699号-3 )

GMT+8, 2025-12-23 07:19

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表