Fonction WindowsPromoteStringBuffer (winstring.h)
Crée un HSTRING à partir du HSTRING_BUFFER spécifié.
Syntaxe
HRESULT WindowsPromoteStringBuffer(
HSTRING_BUFFER bufferHandle,
HSTRING *string
);
Paramètres
bufferHandle
Type : [in] HSTRING_BUFFER
Mémoire tampon à utiliser pour le nouveau HSTRING. Vous devez utiliser la fonction WindowsPreallocateStringBuffer pour créer le HSTRING_BUFFER.
string
Type : [out] HSTRING*
HSTRING nouvellement créé qui contient le contenu de bufferHandle.
Valeur retournée
Type : HRESULT
Cette fonction peut retourner l’une de ces valeurs.
Code de retour | Description |
---|---|
|
Le HSTRING a été créé avec succès. |
|
chaîne a la valeur NULL. |
|
bufferHandle n’a pas été créé en appelant la fonction WindowsPreallocateStringBuffer , ou l’appelant a remplacé le caractère NULL de fin dans bufferHandle. |
Remarques
Utilisez la fonction WindowsPromoteStringBuffer pour créer un HSTRING à partir d’un HSTRING_BUFFER. L’appel de la fonction WindowsPromoteStringBuffer convertit la mémoire tampon mutable en un HSTRING immuable. Utilisez la fonction WindowsPreallocateStringBuffer pour créer le HSTRING_BUFFER.
Si l’appel WindowsPromoteStringBuffer échoue, vous pouvez appeler la fonction WindowsDeleteStringBuffer pour ignorer la mémoire tampon mutable.
Chaque appel à la fonction WindowsPromoteStringBuffer doit être mis en correspondance avec un appel correspondant à WindowsDeleteString.
Exemples
L’exemple de code suivant montre comment utiliser la fonction WindowsPromoteStringBuffer .
#include <winstring.h>
int main()
{
HSTRING hString = NULL;
HSTRING_BUFFER hStringBuffer = NULL;
PWSTR strBuffer = NULL;
HRESULT hr = WindowsPreallocateStringBuffer(10, &strBuffer, &hStringBuffer);
if (SUCCEEDED(hr))
{
// Fill in the buffer
hr = WindowsPromoteStringBuffer(hStringBuffer, &hString);
if (SUCCEEDED(hr))
{
WindowsDeleteString(hString);
}
else
{
WindowsDeleteStringBuffer(hStringBuffer);
}
}
}
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 |
Bibliothèque | RuntimeObject.lib |
DLL | ComBase.dll |
Voir aussi
Commentaires
https://aka.ms/ContentUserFeedback.
Bientôt disponible : Tout au long de 2024, nous allons supprimer progressivement GitHub Issues comme mécanisme de commentaires pour le contenu et le remplacer par un nouveau système de commentaires. Pour plus d’informations, consultezEnvoyer et afficher des commentaires pour