如果未升級為 HSTRING,則會捨棄預先配置的字串緩衝區。
語法
HRESULT WindowsDeleteStringBuffer(
HSTRING_BUFFER bufferHandle
);
參數
bufferHandle
類型:[in] HSTRING_BUFFER
要捨棄的緩衝區。 如果 bufferHandle 不是由呼叫 WindowsPreallocateStringBuffer 函式所配置,WindowsDeleteStringBuffer 函式就會引發例外狀況。
傳回值
類型: HRESULT
此函式可以傳回下列其中一個值。
| 傳回碼 | 描述 |
|---|---|
|
已成功捨棄緩衝區。 |
|
bufferHandle 為 NULL。 |
備註
使用 WindowsDeleteStringBuffer 函式來捨棄 WindowsPreallocateStringBuffer 函式所建立但尚未由 WindowsPromoteStringBuffer 函式升級為 HSTRING 的字符串緩衝區。
範例
下列程式代碼範例示範如何使用 WindowsDeleteStringBuffer 函 式。
int main()
{
HSTRING_BUFFER hStringBuffer = NULL;
PWSTR strBuffer = NULL;
HRESULT hr = WindowsPreallocateStringBuffer(10, &strBuffer, &hStringBuffer);
// You hit a case in which you need to discard the buffer.
WindowsStringDeleteBuffer(hStringBuffer);
}
規格需求
| 需求 | 值 |
|---|---|
| 最低支援的用戶端 | Windows 8 [傳統型應用程式 |UWP 應用程式] |
| 最低支援的伺服器 | Windows Server 2012 [傳統型應用程式 |UWP 應用程式] |
| 目標平台 | Windows |
| 標頭 | winstring.h |
| 程式庫 | RuntimeObject.lib |
| Dll | ComBase.dll |
另請參閱