VirtualLock

  BOOL VirtualLock(lpvMem, cbMem)    
  LPVOID lpvMem; /* address of first byte of range to lock */
  DWORD cbMem; /* number of bytes in range to lock */

The VirtualLock function locks the specified range of the processes address space into memory. This range is present whenever the application is running. All pages covered by the range must be committed.

Parameters

lpvMem

Points to the first byte in the range to be locked.

cbMem

Specifies the number of bytes to lock.

Return Value

The return value is TRUE if the function was successful, or FALSE if an error occurred. Use the GetLastError function to obtain extended error information.

Comments

This function cannot be used to lock memory allocated with the PAGE_NOACCESS flag.

The specified range is used to compute the range of pages covered by the lock. A two-byte lock that straddles a page boundary locks both of the pages covered by the range.

See Also

VirtualUnlock