Why does CreateProcess give error 193 (%1 is not a valid Win32 app)
Solution 1:
The most likely explanations for that error are:
- The file you are attempting to load is not an executable file.
CreateProcess
requires you to provide an executable file. If you wish to be able to open any file with its associated application then you needShellExecute
rather thanCreateProcess
. - There is a problem loading one of the dependencies of the executable, i.e. the DLLs that are linked to the executable. The most common reason for that is a mismatch between a 32 bit executable and a 64 bit DLL, or vice versa. To investigate, use Dependency Walker's profile mode to check exactly what is going wrong.
Reading down to the bottom of the code, I can see that the problem is number 1.
Solution 2:
Your Button2Click
and Button3Click
functions pass klad.xls
and smimime.txt
. These files most likely aren't actual executables indeed.
In order to open arbitrary files using the application associated with them, use ShellExecute