一个VC的例子<br><br>void wmain( int argc, TCHAR *argv[ ])<br>{<br> NET_API_STATUS res;<br> SHARE_INFO_2 p;<br> DWORD parm_err = 0;<br><br> if(argc<2)<br> printf("Usage: NetShareAdd server/n");<br> else<br> {<br> //<br> // Fill in the SHARE_INFO_2 structure.<br> //<br> p.shi2_netname = TEXT("TESTSHARE"); <br> p.shi2_type = STYPE_DISKTREE; // disk drive<br> p.shi2_remark = TEXT("TESTSHARE to test NetShareAdd");<br> p.shi2_permissions = 0; <br> p.shi2_max_uses = 4;<br> p.shi2_current_uses = 0; <br> p.shi2_path = TEXT("C://");<br> p.shi2_passwd = NULL; // no password<br> //<br> // Call the NetShareAdd function,<br> // specifying level 2.<br> //<br> res=NetShareAdd(argv[1], 2, (LPBYTE) &p, &parm_err);<br> //<br> // If the call succeeds, inform the user.<br> //<br> if(res==0)<br> printf("Share created./n");<br> <br> // Otherwise, print an error,<br> // and identify the parameter in error.<br> //<br> else<br> printf("Error: %u/tparmerr=%u/n", res, parm_err);<br> }<br> return;<br>}<br>