Hi

I am trying to create a delphi program to autoinstall other multiple utilities such as adobe reader, winamp etc. I am firstly wondering how to execute an external exe file. and also, is there a way to pass mouse clicks through delphi to this external program?

Thanks

Sean Bedford

Hi,
I have an answer to 'how to execute an external exe file'.

Under 'implementation' and before your first procedure type in 'uses ShellAPI;'

After typing that in, add the following code to one of your procedures:

ShellExecute(Handle, 'open', 'type in the directory of your file e.g. c:\test.txt', nil, nil, SW_SHOWNORMAL);

Hope that helps

Thanks, that did the job!

This works fine, but how can I replace the string of the file to execute by my string.

I have:

Var
txt : string;
.
.
txt := 'myprogram.exe'
.
.
ShellExecute(Handle, 'open', txt, nil, nil, SW_SHOWNORMAL);

This gives a compile error:
Incompatible types: 'String' and 'PAnsiChar'

How can I conver my string to PAnsiChar?

You can convert it like any other conversion with pansichar(txt) or, you could have made the variable an ansichar and sent the pointer..

I would recommend you to creating SFX archive and add your executable myprogram.exe as run after extract item. In this way you need not to call shell execute for launching you application.If you want to know more about this then just let me know.
Thanks,
David

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.