SHLockShared

Declaration

Parameters

The dwProcessId argument is the process
identifier (PID) of the process that provides the context for interpreting the
given handle.

Return Value

If successful, the function returns a pointer to the shared memory.
Otherwise, the function returns NULL.

Behaviour

The function treats the hData and
dwProcessId arguments as a pair that together
identify the shared memory. In general, hData will
have been the result of some earlier call to
SHAllocShared
(possibly in some other process) and dwProcessId
will have been the last of the arguments given in that same call to
SHAllocShared.

The handle refers to a file-mapping object that contains the shared memory.
The function duplicates the given handle into the context of the current process
and uses the duplicate to map a view of the file-mapping object into the address
space of the current process. (The view has read-write access. To choose between
read-only and read-write, use
SHLockSharedEx.)

Availability

The SHLockShared function is exported from
SHLWAPI.DLL as ordinal 8 in version 4.71 and higher.

Though this function dates from as long ago as 1997, it was still not
documented by Microsoft in the MSDN Library at least as late as the CD edition
dated January 2004.

The function also exists indirectly as an export from SHELL32.DLL. Indeed,
this existence predates its implementation in SHLWAPI. The NT releases of
SHELL32 version 4.00, as long ago as 1996, and all releases of later SHELL32
versions export
SHLockShared as ordinal 521. From SHELL32 version
4.71, the implementation in SHELL32 is just a jump to the corresponding
implementation imported from SHLWAPI. Late builds of SHELL32 version 6.00 export
the function by name. This change may be related to Microsoft’s programme of
documenting interfaces for compliance with a consent decree. A SHELL32 function
named
_SHLockShared was documented among the
Settlement Program Interfaces in December 2002. The function is said there
to require SHELL32 “version 5.0 or later”, as if to ignore three years or more
of earlier existence.

This page was created on 3rd September 2004 and was last
modified on 15th March 2007.