//映射网络磁盘
void CTestDlg::OnButton5()
{
system("net use z: /del"); //删除之前映射的盘符
CString HostName,UserName,Password;
HostName = "211.1.1.1"; //远程电脑的IP
HostName.Insert(0,"");
HostName += "//testFile"; //共享的目录
UserName="user"; //用户名
Password ="pwd123"; //密码
NETRESOURCE param1;
param1.dwType = RESOURCETYPE_ANY;
param1.lpLocalName = "Z:"; //远程的某个目录映射为本地的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("Succeed!");
}
}
void CTestDlg::OnButton5()
{
system("net use z: /del"); //删除之前映射的盘符
CString HostName,UserName,Password;
HostName = "211.1.1.1"; //远程电脑的IP
HostName.Insert(0,"");
HostName += "//testFile"; //共享的目录
UserName="user"; //用户名
Password ="pwd123"; //密码
NETRESOURCE param1;
param1.dwType = RESOURCETYPE_ANY;
param1.lpLocalName = "Z:"; //远程的某个目录映射为本地的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("Succeed!");
}
}