Share via


WindowsSubstringWithSpecifiedLength, fonction (winstring.h)

Récupère une sous-chaîne à partir de la chaîne spécifiée. La sous-chaîne commence à une position de caractère spécifiée et sa longueur est définie.

Syntaxe

HRESULT WindowsSubstringWithSpecifiedLength(
  HSTRING string,
  UINT32  startIndex,
  UINT32  length,
  HSTRING *newString
);

Paramètres

string

Type : [in] HSTRING

Chaîne d'origine.

startIndex

Type : [in] UINT32

Position du caractère de départ de base zéro d’une sous-chaîne de cette instance.

length

Type : [in] UINT32

Nombre de caractères dans la sous-chaîne.

newString

Type : [out] HSTRING*

Chaîne équivalente à la sous-chaîne qui commence à startIndex dans la chaîne, ou NULL si startIndex est égal à la longueur de la chaîne.

Valeur retournée

Type : HRESULT

Cette fonction peut retourner l’une de ces valeurs.

Code de retour Description
S_OK
La sous-chaîne a été créée avec succès.
E_INVALIDARG
newString a la valeur NULL ou startIndex plus la longueur est supérieure à MAXUINT32, soit 4 294 967 295 ; c’est-à-dire 0xFFFFFFFF hexadécimal.
E_BOUNDS
startIndex est supérieur à la longueur de la chaîne, ou startIndex plus longueur indique une position qui n’est pas dans la chaîne.
E_OUTOFMEMORY
Échec de l’allocation de la nouvelle sous-chaîne.

Remarques

Chaque appel à la fonction WindowsSubstringWithSpecifiedLength doit être mis en correspondance avec un appel correspondant à WindowsDeleteString.

Configuration requise

Condition requise Valeur
Client minimal pris en charge Windows 8 [applications de bureau | Applications UWP]
Serveur minimal pris en charge Windows Server 2012 [applications de bureau | Applications UWP]
Plateforme cible Windows
En-tête winstring.h

Voir aussi

WindowsDeleteString