GetClipboardFormatName function

Retrieves from the clipboard the name of the specified registered format. The function copies the name to the specified buffer.

Syntax


int WINAPI GetClipboardFormatName(
  _In_  UINT   format,
  _Out_ LPTSTR lpszFormatName,
  _In_  int    cchMaxCount
);

Parameters

format [in]

Type: UINT

The type of format to be retrieved. This parameter must not specify any of the predefined clipboard formats.

lpszFormatName [out]

Type: LPTSTR

The buffer that is to receive the format name.

cchMaxCount [in]

Type: int

The maximum length, in characters, of the string to be copied to the buffer. If the name exceeds this limit, it is truncated.

Return value

Type: int

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

If the function fails, the return value is zero, indicating that the requested format does not exist or is predefined. To get extended error information, call GetLastError.

Remarks

Security Considerations

Using this function incorrectly might compromise the security of your program. For example, miscalculating the proper size of the lpszFormatName buffer, especially when the application is used in both ANSI and Unicode versions, can cause a buffer overflow. Also, note that the string is truncated if it is longer than the cchMaxCount parameter, which can lead to loss of information.

Examples

For an example, see Example of a Clipboard Viewer.

Requirements

Minimum supported client

Windows 2000 Professional [desktop apps only]

Minimum supported server

Windows 2000 Server [desktop apps only]

Header

Winuser.h (include Windows.h)

Library

User32.lib

DLL

User32.dll

Unicode and ANSI names

GetClipboardFormatNameW (Unicode) and GetClipboardFormatNameA (ANSI)

See also

Reference
EnumClipboardFormats
RegisterClipboardFormat
Conceptual
Clipboard

 

 

Community Additions

ADD
Show: