Gregor Schneider grschneider@gmail.com wrote:
That made me think: what happens to this field if the ShellExecuteEx call succeeds and the flag SEE_MASK_NOCLOSEPROCESS is not set? Since this check was thought to forward the actual result of the execution i switched to a simpler and (in my eyes) more reliable code. Plus the original code did not use the flag noted in the specification. The link you provided on the other hand makes it look like ShellExecuteEx always sets this field indendent of any flags passed to the function.
To find out the truth one would have to write test cases. It might well be that the implementation we use is partially incorrect. Especially when looking at testman (it works again :-O ) @ shell32_winetest shlexec which still has some failures.
Hi Greg,
Perhaps You already know, but let's spell it out anyway: hInstApp inherits it's traits from WinExec and LoadModule. WinExec used to be declared HINSTANCE WinExec( LPCSTR CmdLine, UINT CmdShow ), and LoadModule also returned a HINSTANCE. At that time they did return the instance handle, i.e the load address, and it was safe to use these low values as error codes, because they were impossible load addresses (they still are).
Even though WinExec/LoadModule's signatures have changed, and we've been given CreateProcess to exert better control, somewhere in the bowels of Microsoft's code I'm convinced it still percolates down to basically the same code to load/launch a module, so the traits remain. And since the shell APIs are mostly just alternate wrappings for standard Win32 APIs, it percolates to there as well.
I don't think we need to bother with test cases for this, we could apply some common sense instead. A quick test shows that both WinExec and LoadModule actually just return 33 when they succeed, so we could(/should?) let hInstApp always reflect load status the same way that WinExec/LoadModule does, regardless of the flags. That's the most polite to users of ShellExecuteEx. Then they can error branch on either one.
In case of doubt, always wear both belt and suspenders ;)
if (ShellExecuteExW( &sei ) == FALSE) return E_FAIL; if ((INT) sei.hInstApp <= 32) return E_UNEXPECTED;
Best Regards // Love
victor martinez <vicmarcal@hotmail.com mailto:vicmarcal@hotmail.com> wrote:
- if (sei.hInstApp <= (HINSTANCE)32) + if ((INT)sei.hInstApp <= 32) As you see i am just learning, so thanks in advance.
To enlighten You: If you look at the assembly listing, You'll see that those two variants generate exactly the same code.
Best Regards // Love