PRB: ShellExecuteEx on a Shortcut Does Not Return hProcess (243378)



The information in this article applies to:

  • Microsoft Win32 Application Programming Interface (API), when used with:
    • Microsoft Windows 95
    • Microsoft Windows 98
    • Microsoft Windows NT Server 4.0
    • Microsoft Windows NT Workstation 4.0
    • the operating system: Microsoft Windows 2000

This article was previously published under Q243378

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, see the following article or articles in the Microsoft Knowledge Base:

179904 HOWTO: Change the Icon of a Shortcut Through IShellLink

REFERENCES

For additional information, see the following article or articles in the Microsoft Knowledge Base:

179904 HOWTO: Change the Icon of a Shortcut Through IShellLink


Modification Type:MinorLast Reviewed:12/20/2004
Keywords:kbprb kbShellGrp KB243378