关于WinExec的问题.
大家看我下面这段代码,有错没有,怎么执行起来总错,提示 "另一个程序正在使用此文件,进程无法访问 ".
void CTtDlg::OnButton1()
{
// TODO: Add your control notification handler code here
CFileDialog dlg(TRUE, "txt ", "*.txt ");
if(dlg.DoModal() == IDOK)
{
CFile file;
VERIFY(file.Open(dlg.GetPathName(),CFile::modeRead));
CString str= "notepad.exe " + file.GetFilePath();
WinExec(str, SW_SHOW);
}
}
[解决办法]
在WinExec之前,把打开的文件关掉
[解决办法]
没有close这个handle?
[解决办法]
fclose(fp);
[解决办法]
void CTtDlg::OnButton1()
{
// TODO: Add your control notification handler code here
CFileDialog dlg(TRUE, "txt ", "*.txt ");
if(dlg.DoModal() == IDOK)
{
CFile file;
VERIFY(file.Open(dlg.GetPathName(),CFile::modeRead));
CString str= "notepad.exe " + file.GetFilePath();
file.Close();
WinExec(str, SW_SHOW);
}
}