Pelles C > General discussions

CreateProcess not found ?

<< < (2/2)

bitcoin:
hello Vortex
And why is that? Is it the key '/k' to or the function ShellExecute?

John Z:

--- Quote from: bitcoin on February 14, 2023, 12:32:07 AM ---And why is that? Is it the key '/k' to or the function ShellExecute?

--- End quote ---

Hi Bitcoin,

It is not due to the '/k' that just keeps the command window from closing, which then allows you to view the results.

It is the ShellExecute because it uses the registry.  Here is an excerpt from Microsoft at:
https://learn.microsoft.com/en-us/windows/win32/api/shellapi/nf-shellapi-shellexecutea


--- Code: ---Because ShellExecute can delegate execution to Shell extensions (data sources, context menu handlers, verb implementations)
 that are activated using Component Object Model (COM), COM should be initialized before ShellExecute is called. Some Shell
extensions require the COM single-threaded apartment (STA) type. In that case, COM should be initialized as shown here:

CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE)

There are certainly instances where ShellExecute does not use one of these types of Shell extension and those
instances would not require COM to be initialized at all. Nonetheless, it is good practice to always initialize COM
before using this function.

This method allows you to execute any commands in a folder's shortcut menu or stored in the registry.
--- End code ---

In this case the needed 'path' which was missing previously is obtained elsewhere. Also note that in many use cases
for ShellExecute you will need coInitializeEx.....

John Z

Vortex:
Hi bitcoin,

John's explanation is correct. ShellExecute can be useful for practical programming.

Navigation

[0] Message Index

[*] Previous page

Go to full version