CString CUSBDlg::GetMobileDrive()
{
CString strDriver;
DWORD id = GetLogicalDrives();
for (int i = 1; i < 26; i++)
{
if ((id & (1 << i)) != 0)
{
CString strDrv = CString(char('A' + i)) + ":";
if (GetDriveType(strDrv) == DRIVE_REMOVABLE)
{
strDriver = strDrv;
return strDriver;
}
}
}
return strDriver;
}以上是本人检测U盘的代码,现在如果我插入了多个U盘,那么就有多个盘符,该如何储存多个盘符呢?后面我需要往这多个U盘复制文件,那又该怎样编写代码呢?麻烦各位师兄指导下,最好能够贴上代码,因为本人完全是查网络自学的MFC,谢谢!
以下为写入文件到U盘CString da=GetMobileDrive();
CString FileName=da+"\\UserNumber.txt"; CStdioFile UserNumber;
CFileException fileException;
if(!UserNumber.Open(FileName,CFile::modeCreate|CFile::typeText|CFile::modeReadWrite),&fileException)
{
UserNumber.WriteString("0-"+str+"-"+time);//把选取的项及获取到的时间写入文本
}
else
{
TRACE("Can't open file %s, error = %u\n",FileName,fileException.m_cause);
}
UserNumber.Close();
字符数组U盘复制文件调用数组赋值
解决方案 »
- 请教一个网络监听的思路
- 感谢各位,,再来一个问题,问了几天都没有care我.!
- 这个路径怎么判断??谢谢!!
- 使用Csocket可以连接多少个服务端?
- 在CMainFrame::OnCreate()执行中能否访问文档类的数据?
- 关于CDatabase::ExecuteSQL()
- 难道用mfc编个对话框也不行么?请教!
- _T("")的问题
- 弱智问题:如何定义指向函数的指针,如何通过该指针来调用函数
- 谁能提<<vc++技术内幕》,《c++primer》的下载地址?? 急急急 !! !
- mysql 和oracle 对于大数据入库的性能及安全那个更好,能分别说说嘛?
- 如何检同一颜色~不同位置的块数~高手来帮忙解答下~~谢谢!!或者给个想法也行!!有图,看了再说
CStringArray CUSBDlg::GetMobileDrive()
{
CStringArray strDriver;
DWORD id = GetLogicalDrives();
for (int i = 1; i < 26; i++)
{
if ((id & (1 << i)) != 0)
{
CString strDrv = CString(char('A' + i)) + ":";
if (GetDriveType(strDrv) == DRIVE_REMOVABLE)
{
strDriver.Add(strDrv);
}
}
}
return strDriver;
}CStringArray da = GetMobileDrive();for (int i = 0; i < da.GetSize(); ++i)
{
CString FileName=da[i]+"\\UserNumber.txt"; CStdioFile UserNumber;
CFileException fileException;
if(!UserNumber.Open(FileName,CFile::modeCreate|CFile::typeText|CFile::modeReadWrite),&fileException)
{
UserNumber.WriteString("0-"+str+"-"+time);//把选取的项及获取到的时间写入文本
}
else
{
TRACE("Can't open file %s, error = %u\n",FileName,fileException.m_cause);
}
UserNumber.Close();
}