PRB: ShellExecuteEx on a Shortcut Does Not Return hProcess

ID: Q243378


The information in this article applies to:
  • Microsoft Win32 Application Programming Interface (API), included with:
    • Microsoft Windows 95
    • Microsoft Windows 98
    • Microsoft Windows NT 4.0
    • Microsoft Windows 2000


SYMPTOMS

When ShellExecuteEx is used to launch a shortcut to a program (for example, a .lnk file), the SHELLEXECUTEINFO.hProcess doesn't get initialized with the handle to the process created by ShellExecuteEx.


CAUSE

ShellExecuteEx obtains an IContextMenu interface associated with the .lnk file and then calls IContextMenu::InvokeCommand to start the shortcut. The CMINVOKECOMMANDINFO or CMINVOKECOMMANDINFOEX structures do not contain a HPROCESS member to return through ShellExecuteEx.


RESOLUTION

The target can be resolved from the shortcut by using the IShellLink interface. The target, which is a file path or an ITEMIDLIST pointer, can then be passed to ShellExecuteEx to obtain the handle to the process that is started.

NOTE: Resolving the shortcut prior to calling ShellExecuteEx still may not return a valid process handle. This can occur if the application being started is already running and a second instance of the application is not allowed, or if a document is being opened through a DDE connection.


STATUS

This behavior is by design.


MORE INFORMATION

Refer to the Platform SDK documentation on the IShellLink interface.

For additional information, please see the following article(s) in the Microsoft Knowledge Base:

Q179904 HOWTO: Change the Icon of a Shortcut Through IShellLink


REFERENCES

For additional information, please see the following article(s) in the Microsoft Knowledge Base:

Q179904 HOWTO: Change the Icon of a Shortcut Through IShellLink

Additional query words:

Keywords : kbLinks kbNTOS400 kbWinOS2000 kbShellGrp kbWinOS95 kbWinOS98 kbDSupport
Version : winnt:4.0
Platform : winnt
Issue type : kbprb


Last Reviewed: November 24, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.