Answers
通过WNetAddConnection2
示例:
CString HostName,UserName,Password;
HostName = " ";//你的计算机名或IP地址
HostName.Insert(0, "\\\\ ");
HostName += "\\共享文件夹 ";
NETRESOURCE param1;
param1.dwType = RESOURCETYPE_ANY;
param1.lpLocalName = "Z: ";
param1.lpRemoteName = (LPTSTR)(LPCTSTR)HostName;
param1.lpProvider = NULL;
DWORD ret = WNetAddConnection2(¶m1,(LPCTSTR)Password,(LPCTSTR)UserName,CONNECT_UPDATE_PROFILE);
if(ret == NO_ERROR)
AfxMessageBox( "映射驱动器成功! ");
else
AfxMessageBox( "映射驱动器失败! ");
T0Tyomi
answered 12 years, 5 months ago