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暂时的被打开,但它会自动关闭。

打开一个HTML页面
   ShellExecute(Handle, 'open', PChar('http://www.festra.com/'), nil, nil, SW_SHOW);

你能通过一个已经注册的文件类型来打开应用程序
   ShellExecute(Handle, 'open', PChar('c:/test/readme.txt'), nil, nil, SW_SHOW);

用windows Explorer 打开一个目录
   ShellExecute(Handle, 'explore', PChar('c:/windows)', nil, nil, SW_SHOW);

运行一个DOS命令并立即返回
   ShellExecute(Handle, 'open', PChar('command.com'), PChar('/c copy file1.txt file2.txt'), nil, SW_SHOW);

运行一个DOS命令并保持DOS窗口存在
   ShellExecute(Handle, 'open', PChar('command.com'), PChar('/k dir'), nil, SW_SHOW);

ShellExecute 使用方法的更多相关文章

  1. javaSE27天复习总结

    JAVA学习总结    2 第一天    2 1:计算机概述(了解)    2 (1)计算机    2 (2)计算机硬件    2 (3)计算机软件    2 (4)软件开发(理解)    2 (5) ...

  2. [转]vc中调用其他应用程序的方法(函数) winexec,shellexecute ,createprocess

    三个SDK函数: WinExec,ShellExecute ,CreateProcess可以实现调用其他程序的要求,其中以WinExec最为简单,ShellExecute比WinExec灵活一些,Cr ...

  3. 2015.1.25 Delphi打开网址链接的几种方法

    Delphi打开网址链接的几种方法1.使用shellapi打开系统中默认的浏览器              首先需在头部引用 shellapi单元即在uses中添加shellapi,这里我们需要知道有 ...

  4. 【总结】清除webbrowser cookie/session的6种方法

    下面是我测试下来的6种清除webbrowser中cookie的6种方法: //方法一:调用 wininet.dll清除cookie (推荐) SuppressWininetBehavior(); // ...

  5. MFC 打开链接的方法

    第一种: system("start explorer http://http://www.baidu.com"); 第二种: ShellExecute(NULL, NULL, _ ...

  6. WampServe修改默认网站目录的方法(转)

    1wamp简介 WampServe集成了Apache.MySQL.PHP.phpmyadmin,支持Apache的mod_rewrite,PHP扩展.Apache模块只需要在菜单“开启/关闭”上点点就 ...

  7. 【转】【C++】ShellExecute, WinExec, CreateProcess 三者的区别

    ShellExecute ShellExecute的功能是运行一个外部程序(或者是打开一个已注册的文件.打开一个目录.打印一个文件等等),并对外部程序有一定的控制. 有几个API函数都可以实现这些功能 ...

  8. Delphi调用外部程序函数:WinExec() 和ShellExecute详解

    1,WinExec():   WinExec主要运行EXE文件,不能运行其他类型的文件.不用引用特别单元.   原型:UINT WinExec(exePath,ShowCmd)   示例,我想要用记事 ...

  9. windows进程的创建方法

    1.WinExec(LPCSTR lpCmdLine,UINT uCmdShow) >>参数: lpCmdLine:指定程序的相对路径或绝对路径,命令行参数 uCmdShow:指定窗口的显 ...

随机推荐

  1. Rxjava的基本使用

    gradle配置: compile 'io.reactivex:rxjava:1.0.9' 观察者: Observer<String> observer = new Observer< ...

  2. bootstrap-datetime 的使用

    bootstrap-datetime js的下载 http://pan.baidu.com/s/1eQnE5dK html的代码 <div class="input-group dat ...

  3. 表连接,如何先筛选再 join

    想先筛选,再join ,语法如下  select * form tab1 left join tab2 on (tab1.size = tab2.size and tab2.name='AAA') 注 ...

  4. caching redirect views leads to memory leak (Spring 3.1)

    在Spring 3.1以及以下版本使用org.springframework.web.servlet.view.UrlBasedViewResolver + cache(如下配置),在会出现任意种re ...

  5. python 模拟用户登录代码

    需求:输入用户名,判断用户是否被锁定,锁定则退出,否则进入密码验证,输入三次错误密码之后此用户被锁定. userlist.txt里,用":"将用户名.密码.状态码分开: [root ...

  6. (转) How to Train a GAN? Tips and tricks to make GANs work

    How to Train a GAN? Tips and tricks to make GANs work 转自:https://github.com/soumith/ganhacks While r ...

  7. Python-SocketServer源码

    贴到博客,地铁上看- """Generic socket server classes. This module tries to capture the various ...

  8. LeetCode----Array

    Remove Duplicates from Sorted Array 思路:两个指针,头指针在0,尾指针从1开始寻找,找到第一个不等于头指针值的数,覆盖掉头指针后面那个数,然后尾指针往后移. pub ...

  9. 《HelloGitHub》之GitHub Bot

    起因 我在github上发起了一个开源项目:<HelloGitHub月刊>,内容是github上收集的好玩,容易上手的开源项目. 目的:因为兴趣是最好的老师,我希望月刊中的内容可以激发读者 ...

  10. [综] PCA降维

    http://blog.json.tw/using-matlab-implementing-pca-dimension-reduction 設有m筆資料, 每筆資料皆為n維, 如此可將他們視為一個mx ...