Re: ShellExecute (Delphi 7 Personal)

Posted by webmaster Guido on May 02, 2003

In Reply to: ShellExecute (Delphi 7 Personal) posted by Joey on May 01, 2003

: I tried making it so that when i clicked a button it did the shellexecute command:
: ShellExecute(Handle, 'open', PChar('command.com'), PChar('/c copy file1.txt file2.txt'), nil, SW_SHOW);
:
: But it says that ShellExecute is undefined... How do i get round this???

You have to add SHELLAPI to the USES directive on top of your unit (SHELLAPI is the unit where the ShellExecute function is defined). For example, if it says:

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls;

then change it to:

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, SHELLAPI; 

Note: the DelphiLand section Code Snips contains an article plus demo about the use of ShellExecute; look under "Running an external application".

Related Articles and Replies:


Delphi FAQ :: Source code :: Tips