Hi all,
After searching quite a bit I found no answer to this question...how can I execute a program parsing it multiple parameters (like ml /c /coff...) using ShellExecute?
I think I can do it with some really creative calls to strcat, but isn't there other way round? Maybe something different than ShellExecute...?
To be more specific, I want the user to pick a source and destination file (through GetOpenFileName), then parse that info to a little app (trying to create a nice GUI here, heh).
Any ideas?
Thanks in advance ;)
After searching quite a bit I found no answer to this question...how can I execute a program parsing it multiple parameters (like ml /c /coff...) using ShellExecute?
I think I can do it with some really creative calls to strcat, but isn't there other way round? Maybe something different than ShellExecute...?
To be more specific, I want the user to pick a source and destination file (through GetOpenFileName), then parse that info to a little app (trying to create a nice GUI here, heh).
Any ideas?
Thanks in advance ;)
You need to concatenate strings manually - or you can use wsprintf if you have a lot of parameters, to avoid using a whole bunch of concats.
You also might want to use CreateProcess instead of ShellExecute, to have better control of the spawned process (and remember to CloseHandle the thread/process handles when you're done with them).
You also might want to use CreateProcess instead of ShellExecute, to have better control of the spawned process (and remember to CloseHandle the thread/process handles when you're done with them).
Thanks for the fast reply, your post solved my doubts :P
I think I'll also give CreateProcess a try...
Thanks again!
I think I'll also give CreateProcess a try...
Thanks again!
Hi again,
It seems I'm facing another problem...I just noticed that the lenght of the string which contains the parameters to parse to the program has a limit imposed by the OS (I assume this, since both ShellExecute and CreateProcess returned SE_ERR_ACCESSDENIED when dealing with large strings). Am I correct?
Also, GetShortPathName didn't work for me, as I need a few paths and it ends up exceeding the "limit".
Can anyone drop some hints? Is there a solution? :sad:
Thank you and sorry if I misinterpreted something and am giving wrong info!
It seems I'm facing another problem...I just noticed that the lenght of the string which contains the parameters to parse to the program has a limit imposed by the OS (I assume this, since both ShellExecute and CreateProcess returned SE_ERR_ACCESSDENIED when dealing with large strings). Am I correct?
Also, GetShortPathName didn't work for me, as I need a few paths and it ends up exceeding the "limit".
Can anyone drop some hints? Is there a solution? :sad:
Thank you and sorry if I misinterpreted something and am giving wrong info!
I'm not sure what the limits on lpApplicationName and, especially, lpCommandLine, are. But there's likely a difference between 9x and NT platforms. I think linux has a 1024-character max commandline?
If you need to pass a *lot* of arguments, I guess you're in control of the child application as well as the caller? In that case, you should make the child application support "response files", which is just a text file containing the commandline.
DOS versions of GNU tools (read: DJGPP) supported those, since the DOS commandline length limit was pretty short.
If you need to pass a *lot* of arguments, I guess you're in control of the child application as well as the caller? In that case, you should make the child application support "response files", which is just a text file containing the commandline.
DOS versions of GNU tools (read: DJGPP) supported those, since the DOS commandline length limit was pretty short.