Board index » delphi » ShellExecute and CopyFile routines

ShellExecute and CopyFile routines

In article <7f7opb$2n...@nnrp1.dejanews.com>, ski...@{*word*104}dude.com says...

Quote
> How does ShellExecute work ?  I want to open a *.txt file and a *.html file
> with the associated program, how do I do it the most simpel way ?

You can say something like:

  var cmd:string;
  ...
  cmd:= 'C:\file.txt';
  ShellExecute(handle, 'open', pChar(cmd), '',
    pChar(extractFilePath(cmd)), SW_SHOWNORMAL);

It also works if cmd is e.g. 'notepad.exe', or even
'http://www.altavista.com' (but use e.g. 'C:\' for the directory path)
in which case the Internet-link will open in your default browser.

Quote
> I want to Copy files from one directory and overwrite the same in antoher
> directory. How is that done in an easy way ?

Say e.g:

  sExistingFile:= 'C:\temp\file.txt';
  sDestDir      := 'C:\directory';
  CopyFile(pChar(sExistingFileName), pChar(sDestDir), false);

This will automatically overwrite if the file exists.

Regards/Stefan
Please find e-mail address here:
http://home.swipnet.se/align/shareware

@@@@@@@@@@@@@@@@@@@   U  R  L  S  E  N  T  R  Y   @@@@@@@@@@@@@@@@@@@

Get Instant Notification of Changes or Updates of Your Favourite Sites!

        ***  F R E E   D O W N L O A D   H E R E :  ***

            http://home.swipnet.se/align/shareware

URLSentry is a Windows shareware application that can be used
to monitor changes in any Web Pages of interest to you.
It runs silently in the system tray, instantly alerting you to
any Web Page Changes or Updates detected.

 

Re:ShellExecute and CopyFile routines


Quote
-----Original Message-----
From: Align Software AB <FindEMailAddr...@OurWebPagePlease.com>

>In article <7f7opb$2n...@nnrp1.dejanews.com>, ski...@{*word*104}dude.com
says...
>> I want to Copy files from one directory and overwrite the same in
antoher
>> directory. How is that done in an easy way ?

>Say e.g:

>  sExistingFile:= 'C:\temp\file.txt';
>  sDestDir      := 'C:\directory';
>  CopyFile(pChar(sExistingFileName), pChar(sDestDir), false);

>This will automatically overwrite if the file exists.

I have had some problems that it does return true even that it 'forgets'
to
copy the file. I have created my own little copyfile rutine, since
windows
own doesn't seem to that stable.
e.g.
if CopyFile(params) then ShowMessage('Succeeded'); will display
succeeded
even that it failed or DID NOT COPY THE FILE AT ALL !!!!!

So I recommand that you use BlockRead/Write instead.

Tervitades/Best regards/Med venlig Hilsen
Sonnich Jensen
sonnich.jen...@novobcs.ee
http://www.novogroup.com/english/

Other Threads