Running applications from DelphiTM: Using ShellExecute (Part 1) {转贴}[1]

[入库:2005年8月18日] [更新:2007年3月24日]

本文简介:选择自 ihihonline 的 blog

running applications from delphitm: using shellexecute (part 1)

level: newbie-hacker
author: the baker
date: 2002-04-19

 

running or opening external programs or files, from delphitm applications, is often a necessary requirement. this article covers the shellexecute windows api function, revealing techniques for running external applications from your delphi applications.

running applications from delphi

there are a number of reasons why you might be interested in running external applications from your delphi application. often programs are segmented into a number of logical divisions to represent different components of a larger system. some sub-system components might include:

  • main application

  • setup/installer application

  • system application (specifying system wide options)

  • application server application

  • reporting application

  • an external third party application

as can be seen, there are a number of reasons why you might need to call an external application. let's discuss how we can do this with the shellexecute command.

shellexecute winapi

the shellexecute api allows for the execution (or "running") of external applications. it also has a number of other uses, however these all involve performing operations on external files. the syntax for the shellexecute winapi function is:

hinstance shellexecute(hwnd hwnd,
     lpctstr lpoperation,
     lpctstr lpfile,
     lpctstr lpparameters,
     lpctstr lpdirectory,
     int nshowcmd
);

the following is a description of the parameters for the shellexecute function.

parameter input/output description

hwnd

input

handle to the parent window: needed for error reporting.

lpoperation

input

pointer to a null-terminated string. this is the action to be performed (the "object verb")

lpfile

input

pointer to a null-terminated string that specifies the file or object to execute the specified verb on.

lpparameters

input

pointer to a null-terminated string that specifies the parameters to be passed to the application (if the lpfile is an application file). otherwise, this should be null.

lpdirectory

input

pointer to a null-terminated string that specifies the default directory.

nshowcmd

input

flag determining how the application window will be displayed when it is opened.

本文关键:Running applications from DelphiTM: Using ShellExecute (Part 1) {转贴}
  相关方案
Google
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top