Export (0) Print
Expand All

StrCpyN function

Copies a specified number of characters from the beginning of one string to another.

Note  Do not use this function or the StrNCpy macro. See Remarks for alternative functions.

Syntax


PTSTR StrCpyN(
  _Out_  PTSTR pszDst,
  _In_   PCTSTR pszSrc,
  int cchMax
);

Parameters

pszDst [out]

Type: PTSTR

A pointer to a buffer that, when this function returns successfully, receives the copied string. This buffer must be of sufficient size to hold the copied characters. This string is not guaranteed to be null-terminated.

pszSrc [in]

Type: PCTSTR

A pointer to the null-terminated source string.

cchMax

Type: int

The number of characters to be copied, including the terminating null character.

Return value

Type: PTSTR

Returns a pointer to pszDst.

Remarks

Security Warning:  Using this function incorrectly can compromise the security of your application. The copied string is not guaranteed to be null-terminated. Consider using one of the following alternatives. StringCbCopy, StringCbCopyEx, StringCbCopyN, StringCbCopyNEx, StringCchCopy, StringCchCopyEx, StringCchCopyN, StringCchCopyNEx. You should review Security Considerations: Microsoft Windows Shell before continuing.

Requirements

Minimum supported client

Windows 2000 Professional, Windows XP [desktop apps only]

Minimum supported server

Windows 2000 Server [desktop apps only]

Header

Shlwapi.h

Library

Shlwapi.lib

DLL

Shlwapi.dll (version 4.71 or later)

Unicode and ANSI names

StrCpyNW (Unicode)

 

 

Community Additions

ADD
Show:
© 2014 Microsoft