QT 用Windows的API函数,调用打开方式对话框
来源:互联网 发布:淘宝星级怎么快速升级 编辑:程序博客网 时间:2024/05/16 15:03
下面的代码实现的功能是,先用Windows的ShellExecuteW函数以默认的方式打开文本文件,如果文件打开失败,则用WinExec函数调用打开方式对话框。
注意要引入头文件#include <windows.h> 和 #include <shellapi.h>
QString file = "C:/新建/中文.txt";
int nRes = 0;
//以默认方式打开文件
nRes = (int)ShellExecuteW(NULL
, QString("open").toStdWString().c_str()
, file.toStdWString().c_str()
, NULL
, NULL
, SW_SHOW
);
int nRes2 = 0;
char* cmd = QString("rundll32 shell32, OpenAs_RunDLL %1")
.arg(file)
.toLocal8Bit().data();
if(nRes <= SE_ERR_NOASSOC )
{//ShellExecuteW 返回值小于31表示执行出现错误,
//调用打开方式对话框
nRes2 =WinExec(cmd
,SW_SHOWNORMAL
);
}
附相关资料:
http://baike.baidu.com/view/1044533.htm#sub1044533
- QT 用Windows的API函数,调用打开方式对话框
- Delphi调用Windows打开方式对话框示例
- 使用Windows API函数显示打开文件对话框
- windows api打开文件对话框
- QT调用windows、api
- 用API函数调用公用对话框
- Windows API调用对话框资源
- c调用api打开文件对话框
- Access利用Windows API打开文件对话框
- MFC应用程序中打开模式对话框的函数调用顺序
- MFC应用程序中打开模式对话框的函数调用顺序
- c#调用Windows API函数的方法
- 通过API函数打开QQ对话框
- 文件对话框的打开方式
- 用Visual C#调用Windows API函数
- 用Visual C#调用Windows API函数
- 用Visual C#调用Windows API函数
- 用Visual C#调用Windows API函数
- Android屏幕切换效果实现
- MyEclipse开发邮件提示出错。NoClassDefFoundError: com/sun/mail/util/LineInputStream
- Declaring Exports
- 【jQuery插件】用jQuery Masonry快速构建一个pinterest网站布局
- 求助---斐波那契数列
- QT 用Windows的API函数,调用打开方式对话框
- jxl 解析EXCL (项目笔记)
- Spring1--浅谈
- 一个女人的爱情观
- Spring2--IoC
- Microsoft Installer 封装类
- iphone底部出现时间选择器(二)
- 类似于QQ,MSN的右下角消息弹出窗体,使用很简单
- Sqlite存储介绍