MFC如何实现打开一个文件,就像安装完某个程序然后弹出一个readme.txt一样?
来源:互联网 发布:淘宝保证金会退会扣吗 编辑:程序博客网 时间:2024/05/18 01:56
MFC如何实现打开一个文件,就像安装完某个程序然后弹出一个readme.txt一样?
同上
------解决方案--------------------------------------------------------
使用api函数:ShellExecute
Q: 如何打开一个应用程序?
ShellExecute(this-> m_hWnd, "open ", "calc.exe ", " ", " ", SW_SHOW );
或
ShellExecute(this-> m_hWnd, "open ", "notepad.exe ",
"c:\MyLog.log ", " ",SW_SHOW );
Q: 如何打开一个同系统程序相关连的文档?
ShellExecute(this-> m_hWnd, "open ",
"c:\abc.txt ", " ", " ",SW_SHOW );
Q: 如何打开一个网页?
ShellExecute(this-> m_hWnd, "open ", "http://www.google.com ";, " ", " ", SW_SHOW );
Q: 如何激活相关程序,发送EMAIL?
ShellExecute(this-> m_hWnd, "open ",
"mailto:nishinapp@yahoo.com ", " ", " ", SW_SHOW );
Q: 如何用系统打印机打印文档?
ShellExecute(this-> m_hWnd, "print ",
"c:\abc.txt ", " ", " ", SW_HIDE);
Q: 如何用系统查找功能来查找指定文件?
ShellExecute(m_hWnd, "find ", "d:\nish ",
NULL,NULL,SW_SHOW);
Q: 如何启动一个程序,直到它运行结束?
SHELLEXECUTEINFO ShExecInfo = {0};
ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
ShExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
ShExecInfo.hwnd = NULL;
ShExecInfo.lpVerb = NULL;
ShExecInfo.lpFile = "c:\MyProgram.exe ";
ShExecInfo.lpParameters = " ";
ShExecInfo.lpDirectory = NULL;
ShExecInfo.nShow = SW_SHOW;
ShExecInfo.hInstApp = NULL;
ShellExecuteEx(&ShExecInfo);
WaitForSingleObject(ShExecInfo.hProcess,INFINITE);
或:
PROCESS_INFORMATION ProcessInfo;
STARTUPINFO StartupInfo; //入口参数
ZeroMemory(&StartupInfo, sizeof(StartupInfo));
StartupInfo.cb = sizeof StartupInfo ; //分配大小
if(CreateProcess( "c:\winnt\notepad.exe ", NULL,
NULL,NULL,FALSE,0,NULL,
NULL,&StartupInfo,&ProcessInfo))
{
WaitForSingleObject(ProcessInfo.hProcess,INFINITE);
CloseHandle(ProcessInfo.hThread);
CloseHandle(ProcessInfo.hProcess);
}
else
{
MessageBox( "The process could not be started... ");
}
Q: 如何显示文件或文件夹的属性?
SHELLEXECUTEINFO ShExecInfo ={0};
ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
ShExecInfo.fMask = SEE_MASK_INVOKEIDLIST ;
ShExecInfo.hwnd = NULL;
ShExecInfo.lpVerb = "properties ";
ShExecInfo.lpFile = "c:\ "; //也可以是文件
ShExecInfo.lpParameters = " ";
ShExecInfo.lpDirectory = NULL;
同上
------解决方案--------------------------------------------------------
使用api函数:ShellExecute
Q: 如何打开一个应用程序?
ShellExecute(this-> m_hWnd, "open ", "calc.exe ", " ", " ", SW_SHOW );
或
ShellExecute(this-> m_hWnd, "open ", "notepad.exe ",
"c:\MyLog.log ", " ",SW_SHOW );
Q: 如何打开一个同系统程序相关连的文档?
ShellExecute(this-> m_hWnd, "open ",
"c:\abc.txt ", " ", " ",SW_SHOW );
Q: 如何打开一个网页?
ShellExecute(this-> m_hWnd, "open ", "http://www.google.com ";, " ", " ", SW_SHOW );
Q: 如何激活相关程序,发送EMAIL?
ShellExecute(this-> m_hWnd, "open ",
"mailto:nishinapp@yahoo.com ", " ", " ", SW_SHOW );
Q: 如何用系统打印机打印文档?
ShellExecute(this-> m_hWnd, "print ",
"c:\abc.txt ", " ", " ", SW_HIDE);
Q: 如何用系统查找功能来查找指定文件?
ShellExecute(m_hWnd, "find ", "d:\nish ",
NULL,NULL,SW_SHOW);
Q: 如何启动一个程序,直到它运行结束?
SHELLEXECUTEINFO ShExecInfo = {0};
ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
ShExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
ShExecInfo.hwnd = NULL;
ShExecInfo.lpVerb = NULL;
ShExecInfo.lpFile = "c:\MyProgram.exe ";
ShExecInfo.lpParameters = " ";
ShExecInfo.lpDirectory = NULL;
ShExecInfo.nShow = SW_SHOW;
ShExecInfo.hInstApp = NULL;
ShellExecuteEx(&ShExecInfo);
WaitForSingleObject(ShExecInfo.hProcess,INFINITE);
或:
PROCESS_INFORMATION ProcessInfo;
STARTUPINFO StartupInfo; //入口参数
ZeroMemory(&StartupInfo, sizeof(StartupInfo));
StartupInfo.cb = sizeof StartupInfo ; //分配大小
if(CreateProcess( "c:\winnt\notepad.exe ", NULL,
NULL,NULL,FALSE,0,NULL,
NULL,&StartupInfo,&ProcessInfo))
{
WaitForSingleObject(ProcessInfo.hProcess,INFINITE);
CloseHandle(ProcessInfo.hThread);
CloseHandle(ProcessInfo.hProcess);
}
else
{
MessageBox( "The process could not be started... ");
}
Q: 如何显示文件或文件夹的属性?
SHELLEXECUTEINFO ShExecInfo ={0};
ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
ShExecInfo.fMask = SEE_MASK_INVOKEIDLIST ;
ShExecInfo.hwnd = NULL;
ShExecInfo.lpVerb = "properties ";
ShExecInfo.lpFile = "c:\ "; //也可以是文件
ShExecInfo.lpParameters = " ";
ShExecInfo.lpDirectory = NULL;
- MFC如何实现打开一个文件,就像安装完某个程序然后弹出一个readme.txt一样?
- MFC打开一个文件
- 用Windows自带的程序打开一个Txt文件
- C#如何打开一个文件夹并定位到某个文件
- 如何使用java程序打开一个文件?
- 如何和BT一样建立一个比较大的文件,然后再写入
- asp.net 点击一个按钮弹出对话框选择文件然后选择文件完成之后就自动上传文件 input(file)
- MFC C++弹出对话框打开txt文件(例子)
- 用MFC打开一个文件
- 如何点击一个按钮,弹出一个已存在的txt文件
- 实现在自己的程序中点击一个按钮,然后弹出系统自带的联系人
- 如何做到像《金山词霸》一样只运行一个实例
- 如何写一个像UIImagePicker一样的自定义图片选择器
- 如何设计一个像人的大脑皮层一样的产品?
- 汇编语言: 编写一个程序,新建一个文件:d:\abc.txt,从键盘输入文件的内容(不超过100个字 符)。然后新建一个文件:d:\def.txt,将d:\abc.txt文件的内容复制到d:\def.
- MFC 程序中调用记事本 NotePad 打开 txt 文件
- 新建一个win32空工程,然后使用MFC创建程序
- Winform 实现像菜单一样弹出层
- Arcgis server 安装破解教程
- android XML转义字符
- Android 向Tomcat服务器提交中文乱码问题解决
- Jython小问题-字符编码
- 71道经典Android面试题和答案
- MFC如何实现打开一个文件,就像安装完某个程序然后弹出一个readme.txt一样?
- Struts2 采用convention-plugin实现零配置
- js获取图片点坐标值
- 统一数据库集群
- php - 一些好习惯
- ProgressBar更新
- iphone ios layer 教程应用
- 系统签名,共享用户ID
- Error : Failed to create sdcard in the AVD folder.