retep
asked on
Alternative to WinExec
I need to start different programs from my own program.
I store the address to the programs in TFilename's.
What I do is this:
I have a variable (FileN) of TFilename.
if WinExec(PChar(FileN),SW_SH OW)<32 then
begin
messagedlg('error', mtInformation,[mbOk], 0)
end;
But it only work for programs that does not access other files. It seems that the programs I load with WinExec search for the files they need in the folder of my program.
How do I tell them to act as if they were executed from their own folder?
I store the address to the programs in TFilename's.
What I do is this:
I have a variable (FileN) of TFilename.
if WinExec(PChar(FileN),SW_SH
begin
messagedlg('error', mtInformation,[mbOk], 0)
end;
But it only work for programs that does not access other files. It seems that the programs I load with WinExec search for the files they need in the folder of my program.
How do I tell them to act as if they were executed from their own folder?
Tell us more about "But it only work for programs that does not access other files". You might try using ShellExecute(...), but I don't know exactly what you mean.
Sorry, I just re-read your question and understand - I think ShellExecute works.
ASKER
Could you show me how ShellExecute works? And which unit I need to add in my uses-clause...
Thanks :)
Thanks :)
If you have D2 or above, it's in the windows unit, which is in your uses clause as a default. I can't remember the parameters - and I'm not on a computer with Delphi on at the moment, but search for it in the Win32.hlp help file. I think it might go something like ShellExecute(handle,'c:\Ga me.exe','o pen'...).
there are also plenty of examples inthe ee paq's.
Gl
Mike
Gl
Mike
Hi!
Try using SW_NORMAL in stead of SW_SHOW...
Try using SW_NORMAL in stead of SW_SHOW...
ASKER
bogieman>> I have Delphi4, but it doesn't recognice ShellExecute(..) ???!
Anyone who knows how to use it?
Grayl1>> I have tried SW_NORMAL... No success...
Anyone who knows how to use it?
Grayl1>> I have tried SW_NORMAL... No success...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
In other words, don't pass a nil to the Directory parameter in ShellExecute, instead pass along the directory that you wish for the programme to start in.
Cheers,
DragonSlayer
Cheers,
DragonSlayer
ASKER
This was the closest I got to a whole answer. Therefore DrDelphi gets the points... Hope the rest of you doesn't feel to cheated...
Thanks to all of you.
Regards
Retep :-)
Thanks to all of you.
Regards
Retep :-)