Board index » delphi » HELP: How to execute an external program???

HELP: How to execute an external program???

Hi,
Can anyone tell me how to execute an external program from within a
Delphi program? I tried to use ShellEXECUTE, but I keep getting a
Variant Error when I'm transmitting a PCHAR pointer to the
paramaterstring. If I transmit a NULL instead of a pointer, I the
program won't even compile because of a 'Type Mismatch'. Can anyone help
me? Pleeeeaaaaaze!! :)

Thanx in advance!

---------------------------------------------
 Eric J. Francois   CIS: 102330,3121
  Internet: eric.franc...@vo.lu
  WWW: http://www.vo.lu/homepages/efrancois
---------------------------------------------
 "I object to all that sex on TV!
  ... I mean, I keep falling off!"
                              (Monty Python)
---------------------------------------------

 

Re:HELP: How to execute an external program???


Quote
Eric J. Francois wrote:

> Hi,
> Can anyone tell me how to execute an external program from within a
> Delphi program? I tried to use ShellEXECUTE, but I keep getting a
> Variant Error when I'm transmitting a PCHAR pointer to the
> paramaterstring. If I transmit a NULL instead of a pointer, I the
> program won't even compile because of a 'Type Mismatch'. Can anyone
> help me? Pleeeeaaaaaze!! :)

> Thanx in advance!

> ---------------------------------------------
>  Eric J. Francois   CIS: 102330,3121
>   Internet: eric.franc...@vo.lu
>   WWW: http://www.vo.lu/homepages/efrancois
> ---------------------------------------------
>  "I object to all that sex on TV!
>   ... I mean, I keep falling off!"
>                               (Monty Python)
> ---------------------------------------------

depending on what app you want to start, you can use WinExec which is
very simple. If you try using CreateProcess, follow the answers I'mm
getting on my problem. Hope someone answers that.

WinExec only needs 2 params, the app name and how you want to start it:

eg:

        WinExec('notepad',SW_SHOW);

        Koen De Clercq
        Koen.DeCle...@teledata.be

Re:HELP: How to execute an external program???


Quote
>Hi,
>Can anyone tell me how to execute an external program from within a
>Delphi program? I tried to use ShellEXECUTE, but I keep getting a
>Variant Error when I'm transmitting a PCHAR pointer to the
>paramaterstring. If I transmit a NULL instead of a pointer, I the
>program won't even compile because of a 'Type Mismatch'. Can anyone help
>me? Pleeeeaaaaaze!! :)

>Thanx in advance!

Try WinExec or WinExecute (I don't remember)

Sylvain Fortin
Computer Programmer
Montreal (Quebec)
sylva...@videotron.ca

Re:HELP: How to execute an external program???


On Sat, 18 Jan 1997 23:13:47 +0100, Support - Teledata Systems NV

Quote
<supp...@teledata.be> wrote:

Have a look at the FMXUtils.pas file that comes with Delphi 2.0
it has a method called ExecuteFile which is exactly what you are
looking for. It uses ShellExecute properly.

Cheers.
Stephen.
s...@c031.aone.net.au

Quote
>Eric J. Francois wrote:

>> Hi,
>> Can anyone tell me how to execute an external program from within a
>> Delphi program? I tried to use ShellEXECUTE, but I keep getting a
>> Variant Error when I'm transmitting a PCHAR pointer to the
>> paramaterstring. If I transmit a NULL instead of a pointer, I the
>> program won't even compile because of a 'Type Mismatch'. Can anyone
>> help me? Pleeeeaaaaaze!! :)

>> Thanx in advance!

>> ---------------------------------------------
>>  Eric J. Francois   CIS: 102330,3121
>>   Internet: eric.franc...@vo.lu
>>   WWW: http://www.vo.lu/homepages/efrancois
>> ---------------------------------------------
>>  "I object to all that sex on TV!
>>   ... I mean, I keep falling off!"
>>                               (Monty Python)
>> ---------------------------------------------

>depending on what app you want to start, you can use WinExec which is
>very simple. If you try using CreateProcess, follow the answers I'mm
>getting on my problem. Hope someone answers that.

>WinExec only needs 2 params, the app name and how you want to start it:

>eg:

>    WinExec('notepad',SW_SHOW);

>    Koen De Clercq
>    Koen.DeCle...@teledata.be

Re:HELP: How to execute an external program???


Eric J. Francois <efranc...@vo.lu> wrote in note <32E106ED.2...@vo.lu>...

Quote
> Can anyone tell me how to execute an external program from within a
> Delphi program? I tried to use ShellEXECUTE, but ...

Try the WinExec function:

        WinExec('C:\MYPROG.EXE',SW_SHOWNORMAL);

Hope this helps,

        Tomas

Re:HELP: How to execute an external program???


Eric,
  Try looking at the section on " Executing an application " in Delphi's
User Guide (pg. 375 in D1, pg. 346 in D2).  This should provide you with
the info you need.

Hope this helps!
--
Rod Geraghty (:>)
GERA-Tech
Ottawa, Canada
gera...@ibm.net

Eric J. Francois <efranc...@vo.lu> wrote in article
<32E106ED.2...@vo.lu>...

Quote
> Hi,
> Can anyone tell me how to execute an external program from within a
> Delphi program?
>(Snip)

Re:HELP: How to execute an external program???


thanks for the pointer to the Delphi 2 utils - I will check it out.
Meanwhile, I use ShellExecute in Delphi 1 and posted some
working code to alt.lang.delphi - running Internet Explorer is the topic.
 It may have some value!
I don't pass variants, just mere strings with appended #0 to make
them into null-terminated strings  -  good enough !
Regards
Iris Radulescu

Stephen Graham <s...@c031.mel.aone.net.au> wrote in article
<32e21463.656...@news.mel.aone.net.au>...

Quote
> On Sat, 18 Jan 1997 23:13:47 +0100, Support - Teledata Systems NV
> <supp...@teledata.be> wrote:

> Have a look at the FMXUtils.pas file that comes with Delphi 2.0
> it has a method called ExecuteFile which is exactly what you are
> looking for. It uses ShellExecute properly.

> Cheers.
> Stephen.
> s...@c031.aone.net.au

> >Eric J. Francois wrote:

> >> Hi,
> >> Can anyone tell me how to execute an external program from within a
> >> Delphi program? I tried to use ShellEXECUTE, but I keep getting a
> >> Variant Error when I'm transmitting a PCHAR pointer to the
> >> paramaterstring. If I transmit a NULL instead of a pointer, I the
> >> program won't even compile because of a 'Type Mismatch'. Can anyone
> >> help me? Pleeeeaaaaaze!! :)

Other Threads