This topic has not yet been rated - Rate this topic

SHSetInstanceExplorer function

Applies to: desktop apps only

Provides an interface that allows hosted Shell extensions and other components to prevent their host process from closing prematurely. The host process is typically Windows Explorer or Windows Internet Explorer, but this function can also be used by other applications.

Syntax

void SHSetInstanceExplorer(
  __in_opt  IUnknown *punk
);

Parameters

punk [in, optional]

Type: IUnknown*

A pointer to a free-threaded IUnknown. Components can use this interface (through SHGetInstanceExplorer) to prevent the host process from terminating. This value can be NULL, in which case the process reference is no longer made available to components.

Return value

This function does not return a value.

Remarks

Windows Explorer and Internet Explorer can use SHSetInstanceExplorer to allow components such as Shell extensions to extend the lifetime of the process. Other applications can also use SHSetInstanceExplorer to allow for the same capability. For instance, the browser message loop and the proxy desktop use SHSetInstanceExplorer to let other threads extend their lifetime.

Applications other than Windows Explorer and Internet Explorer that call this function might encounter compatibility problems because some components use SHGetInstanceExplorer to detect whether they are being hosted from within Windows Explorer or Internet Explorer.

The interface pointer passed to SHSetInstanceExplorer must reference a free-threaded object.

Each time a component calls SHGetInstanceExplorer, the system calls the AddRef method before returning the interface pointer to the calling component. The component then calls the IUnknown::Release method when processing is complete. The process that calls SHSetInstanceExplorer must not terminate while the reference count of the provided interface pointer is nonzero.

For further information on how components use the process references, see SHGetInstanceExplorer.

Requirements

Minimum supported client

Windows XP

Minimum supported server

Windows Server 2003

Header

Shlobj.h

Library

Shell32.lib

DLL

Shell32.dll (version 5.0 or later)

See also

SHGetInstanceExplorer

 

 

Send comments about this topic to Microsoft

Build date: 3/7/2012

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ