//读取网络路径下的文件夹
void CCTimeDlg::OnBnClickedButton2()
{
UpdateData(TRUE);
TCHAR cstr1[MAX_PATH];
TCHAR cstr2[MAX_PATH];
_stprintf(cstr1, L"echo 在%s 的共享资源>D:\\data.txt", m_ServerPath);
_stprintf(cstr2, L"net view %s >D:\\data.txt", m_ServerPath);
int Length1 = WideCharToMultiByte(CP_ACP, 0, cstr1, -1, NULL, 0, NULL, NULL);
char* str1 = new char[Length1];
WideCharToMultiByte(CP_ACP, 0, cstr1, -1, str1, Length1, NULL, NULL);
int Length2 = WideCharToMultiByte(CP_ACP, 0, cstr2, -1, NULL, 0, NULL, NULL);
char* str2 = new char[Length2];
WideCharToMultiByte(CP_ACP, 0, cstr2, -1, str2, Length2, NULL, NULL);
//system(str1);
//system(str2);
ShellExecute(0, L"open", L"cmd", L"/C dir", 0, SW_HIDE); // dir可为任意命令
CString cmdstr1,cmdstr2;
cmdstr1.Format(L"/C echo 在%s 的共享资源>D:\\data.txt", m_ServerPath);
cmdstr2.Format(L"/C net view %s >D:\\data.txt", m_ServerPath);
ShellExecute(0, L"open", L"cmd", cmdstr1, 0, SW_HIDE);
ShellExecute(0, L"open", L"cmd", cmdstr2, 0, SW_HIDE);
}
读取网络路径下的文件夹,重定向到本地文件
最新推荐文章于 2023-05-09 19:57:09 发布