Re: ShellExecute and copy, delete command

From: Tim Robinson (tim.at.gaat.freeserve.co.uk_at_invalid.com)
Date: 04/14/04


Date: Wed, 14 Apr 2004 19:44:15 +0100

Gary wrote:
[...]
> Then I tried ShellExecute(NULL,
> "open", "copy", "sourcefile destfile", "", SW_HIDE), but it failed.
> 0x00000002 returned as the HINSTANCE variable. I guess it means
> "Could not find the path" or something.

The COPY command is internal to the Command Prompt, CMD.EXE. ShellExecute is
looking for a program called COPY.EXE which doesn't exist.

> Is that possible to use
> ShellExecute to do the file manipulation job? If we cann't, how to
> do that in a hide window?

You could use ShellExecute to spawn a copy of CMD.EXE to do the copy, but
that's the hard way. It's much better to use the built-in Win32 functions to
do what you want: CopyFile, MoveFile, DeleteFile and the rest. You might
also want to look at SHFileOperation, which Explorer uses to copy, move,
delete etc. files.

-- 
Tim Robinson (MVP, Windows SDK)
http://mobius.sourceforge.net/


Relevant Pages

  • Re: ShellExecute
    ... The redirection operators, are part of the command ... Althought this API function is called "shellexecute" I doubt ... it's sending the command to the CLI; rather, ...
    (borland.public.delphi.nativeapi)
  • Re: send email with shellexecute but crlf in body does not work
    ... like opening up a DOS window and typing a command. ... > I try to send an email with shellexecute in FVP8 on Win2k with Outlook ... > Unfortunately the body text will not show my crlf. ...
    (microsoft.public.fox.programmer.exchange)
  • Re: autorun.inf
    ... shellexecute e.. ... Remarks ... The open command specifies the path and file name of the application that AutoRun launches when a user inserts a disc in the drive. ... verb The verb that corresponds to the command. ...
    (microsoft.public.windowsxp.general)
  • Re: remove non empty direcory
    ... ShellExecute will execute any command you can pass to the Start/Run... ... You'd test whether a directory exists by calling CreateDirectory and ...
    (microsoft.public.vc.language)
  • Re: RUN command fails
    ... The RUN command is working fine. ... STRING cParameters ... > But you should use the ShellExecute API function. ... >> Error message: ...
    (microsoft.public.fox.programmer.exchange)

Quantcast