dedecms织梦内容管理系统    
首页 | java | C/C++ | PHP | 操作系统 | ajax | 脚本编程 | 安全技术 | 本站下载页 | 专题 | QQ群 | 测试中心 | 会员中心 | 积分规则
  当前位置:主页>操作系统>windows>文章内容
深入浅出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;

ShExecInfo.nShow = SW_SHOW;

ShExecInfo.hInstApp = NULL;

ShellExecuteEx(&ShExecInfo);

上一篇:ShellExecute使用详解   下一篇:一个flex正则表达式的例子
[收藏] [推荐] [评论(0条)] [返回顶部] [打印本页] [关闭窗口]  
用户名: 新注册) 密码: 匿名评论
评论内容:(不能超过250字,需审核后才会公布,请自觉遵守互联网相关政策法规。
 §最新评论
  热点文章
·别浪费你的大内存 如何给Windows
·Vista系统下使用率最高的11条命
·教你快速释放Windows系统资源的
·Linux和Windows系统调用的比较
·Cygwin使用指南
·容量不足 奥运门票销售系统全面
·Windows系统中鲜为人知的宝藏之
·Windows系统中鲜为人知的宝藏之
·Windows系统中鲜为人知的宝藏之
·Windows系统中鲜为人知的宝藏之
·Windows系统目录功能揭密
·网络上最经典的DOS命令!(三)
  相关文章
·ShellExecute使用详解
·凤凰卫视闾丘露薇-从vista的霸道
·Windows XP和2000操作系统自动关
·DOS与Windows 98的共存
·XP实用技巧:远程协助
·XP技巧五则
·解析七大Windows系统故障
·让计算机启动更快的十五招
·IE问题集锦
·windows xp搜索功能异常的解决方
·当Windows 2000不能启动时
·Windows xp优化设置及相关问题的
  相关信息
copy right @ 百家拳软件项目研究室 2007 辽ICP备07011763