0 out of 1 rated this helpful - Rate this topic

GetMappedFileName function

Applies to: desktop apps only

Checks whether the specified address is within a memory-mapped file in the address space of the specified process. If so, the function returns the name of the memory-mapped file.

Syntax

DWORD WINAPI GetMappedFileName(
  __in   HANDLE hProcess,
  __in   LPVOID lpv,
  __out  LPTSTR lpFilename,
  __in   DWORD nSize
);

Parameters

hProcess [in]

A handle to the process. The handle must have the PROCESS_QUERY_INFORMATION and PROCESS_VM_READ access rights. For more information, see Process Security and Access Rights.

lpv [in]

The address to be verified.

lpFilename [out]

A pointer to the buffer that receives the name of the memory-mapped file to which the address specified by lpv belongs.

nSize [in]

The size of the lpFilename buffer, in characters.

Return value

If the function succeeds, the return value specifies the length of the string copied to the buffer, in characters.

If the function fails, the return value is zero. To get extended error information, call GetLastError.

Remarks

Starting with Windows 7 and Windows Server 2008 R2, Psapi.h establishes version numbers for the PSAPI functions. The PSAPI version number affects the name used to call the function and the library that a program must load.

If PSAPI_VERSION is 2 or greater, this function is defined as K32GetMappedFileName in Psapi.h and exported in Kernel32.lib and Kernel32.dll. If PSAPI_VERSION is 1, this function is defined as GetMappedFileName in Psapi.h and exported in Psapi.lib and Psapi.dll as a wrapper that calls K32GetMappedFileName.

Programs that must run on earlier versions of Windows as well as Windows 7 and later versions should always call this function as GetMappedFileName. To ensure correct resolution of symbols, add Psapi.lib to the TARGETLIBS macro and compile the program with -DPSAPI_VERSION=1. To use run-time dynamic linking, load Psapi.dll.

Examples

For an example, see Obtaining a File Name From a File Handle.

Requirements

Minimum supported client

Windows XP

Minimum supported server

Windows Server 2003

Header

Psapi.h

Library

Kernel32.lib on Windows 7 and Windows Server 2008 R2;
Psapi.lib (if PSAPI_VERSION=1) on Windows 7 and Windows Server 2008 R2;
Psapi.lib on Windows Server 2008, Windows Vista, Windows Server 2003, and Windows XP

DLL

Kernel32.dll on Windows 7 and Windows Server 2008 R2;
Psapi.dll (if PSAPI_VERSION=1) on Windows 7 and Windows Server 2008 R2;
Psapi.dll on Windows Server 2008, Windows Vista, Windows Server 2003, and Windows XP

Unicode and ANSI names

GetMappedFileNameW (Unicode) and GetMappedFileNameA (ANSI)

See also

EnumProcesses
Memory-Mapped File Information
PSAPI Functions

 

 

Send comments about this topic to Microsoft

Build date: 2/7/2012

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
noname files ?
http://msdn.microsoft.com/en-us/library/windows/desktop/aa366537(v=vs.85).aspx mm-Files cn be created without name. Docs say that not OS would make auto-generated name stub, but the object would have just no any name. What would be returned then ? 0 as function value, yer ERROR_SUCCESS for Get Last Error ? Or what ? Documentation is to specify, what would be the function's behavior if no file name exists.