vc打开txt文件无法实现

来源:百度知道 编辑:UC知道 时间:2024/06/01 12:23:14
使用ShellExecute打开文件,如若在函数里直接写文件名可以实现,但是若改成编辑框的变量则无法实现,为什么?
我在编辑框中输入C://新建文本文档.txt,希望借助ShellExecute打开改文档,为何无法实现。
程序段如下:
void CMyDlg::OnButton3()
{
// TODO: Add your control notification handler code here
//CFileDialog dlg(true);
UpdateData(true);
AfxMessageBox(m_strFileName);
//if(IDOK==dlg.DoModal())
// {
// m_strOpenName=dlg.GetPathName();
ShellExecute(NULL,"open","m_strFileName",NULL,NULL,SW_SHOW);
// UpdateData(false);
//}
}

shellexecute的参数filename不是字符串,而是变量名!干嘛加双引号呢?
打开一个txt还用那么麻烦?
#include <iostream>
system("start 路径");
或者用createprocess函数等
方法还有很多种