在一个网站看资料时,发现一个关于WINDOWS API函数的学习资料,翻译下来认初学者更快的了解这个API的使用。
ShellExecute的功能是运行一个外部程序(或者是打开一个已注册的文件、打开一个目录、打印一个文件等等),并对外部程序有一定的控制。
有几个API函数都可以实现这些功能,但是在大多数情况下ShellExecute是更多的被使用的,同时它并不是太复杂。下面举例说明它的用法。
ShellExecute(Handle, ''''open'''', PChar(''''c:\test\app.exe''''), nil, nil, SW_SHOW);
- 打开记事本,并打开一个文件(系统能识别记事本应用程序的路径,因此我们不必使用绝对路径)
ShellExecute(Handle, ''''open'''', PChar(''''notepad''''), PChar(''''c:\test\readme.txt''''), nil, SW_SHOW);
ShellExecute(Handle, ''''print'''', PChar(''''c:\test\test.doc''''), nil, nil, SW_SHOW);
注意:可能你会看到word暂时的被打开,但它会自动关闭。
ShellExecute(Handle, ''''open'''', PChar(''''http://www.festra.com/''''), nil, nil, SW_SHOW);
ShellExecute(Handle, ''''open'''', PChar(''''c:\test\readme.txt''''), nil, nil, SW_SHOW);
ShellExecute(Handle, ''''explore'''', PChar(''''c:\windows)'''', nil, nil, SW_SHOW);
ShellExecute(Handle, ''''open'''', PChar(''''command.com''''), PChar(''''/c copy file1.txt file2.txt''''), nil, SW_SHOW);
ShellExecute(Handle, ''''open'''', PChar(''''command.com''''), PChar(''''/k dir''''), nil, SW_SHOW);
[系统软件]windows下Apache+php+mysql的安装与配置图解 [操作系统]在Windows中玩转Linux操作系统 [操作系统]死马还当活马医:6种方法挽救Windows系统 [聊天工具]四大更新 Windows Live Msn 8.1评测 [聊天工具]Windows Live Messenger最新0683版亮相_联络工具_… [聊天工具]Windows Live Mail招人爱的N个理由_联络工具_Wind… [聊天工具]Windows Live Mail Desktop多图欣赏_联络工具_Win… [聊天工具]OE老了 微软开发新邮件客户端取而代之_联络工具 [聊天工具]Windows Live Messenger中文版试用报告(一)__天极… [聊天工具]Windows Live Messenger 8 Beta1高清图赏__天极Ye…
|