LockResource Function

Locks the specified resource in memory.

Syntax

LPVOID LockResource(      
    HGLOBAL hResData );

Parameters

hResData
[in] Handle to the resource to be locked. The LoadResource function returns this handle. Note that this parameter is listed as an HGLOBAL variable only for backward compatibility. Do not pass any value as a parameter other than a successful return value from the LoadResource function.

Return Value

If the loaded resource is locked, the return value is a pointer to the first byte of the resource; otherwise, it is NULL.

Remarks

The pointer returned by LockResource is valid until the module containing the resource is unloaded. It is not necessary to unlock resources because the system automatically deletes them when the process that created them terminates.

Do not try to lock a resource by using the handle returned by the FindResource or FindResourceEx function. Such a handle points to random data.

Example

For an example, see Updating Resources.

Function Information

Minimum DLL Versionkernel32.dll
HeaderDeclared in Winbase.h, include Windows.h
Import libraryKernel32.lib
Minimum operating systems Windows 95, Windows NT 3.1
UnicodeImplemented as Unicode version.

See Also

Tags :


Community Content

dmex
vb.net syntax
<DllImport("kernel32.dll", SetLastError:=True)> _
Public Shared Function LockResource(ByVal hResData As IntPtr) As IntPtr
End Function
Tags : vb.net syntax

dmex
C# syntax
[DllImport("kernel32.dll", SetLastError=true)]
internal static extern IntPtr LockResource(IntPtr hResData);
Tags : c# syntax

Page view tracker