VC++共享文件夹

 1 BOOL NetShare(char * pShareName,char * pSharePath)
 2 {
 3 USES_CONVERSION;
 4 SHARE_INFO_502 si502; 
 5 NET_API_STATUS nas; 
 6 LPWSTR pwShareName=A2W(pShareName); //转换成unicode 字符串
 7 LPWSTR pwSharePath=A2W(pSharePath);
 8 
 9 si502.shi502_netname = (LPWSTR)pwShareName; 
10 si502.shi502_type = STYPE_DISKTREE; 
11 si502.shi502_remark = NULL; 
12 si502.shi502_permissions = 0; 
13 si502.shi502_max_uses = /*SHI_USES_UNLIMITED*/1; 
14 si502.shi502_current_uses = 0; 
15 si502.shi502_path = (LPWSTR)pwSharePath; 
16 si502.shi502_passwd = NULL; 
17 si502.shi502_reserved = 0; 
18 si502.shi502_security_descriptor = NULL ;
19 
20 nas = NetShareAdd( 
21 NULL, // share is on local machine 
22 502, // info-level 
23 (LPBYTE)&si502, // info-buffer 
24 NULL // don't bother with parm 
25 );
26 
27 return (nas==0);
28 }
29 
30 ?1234567BOOL NetShareStop(char * pShareName){ USES_CONVERSION; LPWSTR pwShareName=A2W(pShareName); return NetShareDel( NULL,(LPWSTR)pwShareName,NULL);}

 

posted @ 2016-08-25 22:00  南下玩技术  阅读(660)  评论(0编辑  收藏  举报