gpt4 book ai didi

c++ - 在 VB6 中,我是否需要在使用 SysAllocString 分配的字符串上调用 SysFreeString?

转载 作者:行者123 更新时间:2023-11-30 02:57:44 29 4
gpt4 key购买 nike

我有一个 VB6 应用程序,它使用 C++ COM DLL 并且 BSTR 在两者之间传递。我使用 return::SysAllocString(L"example"); 从 C++ DLL 返回 BSTR。

我是否需要在以下示例中对这样的字符串调用 SysFreeString

Sub Main()
Dim own_str As String
Dim dll_str As String

own_str = "my own string"
dll_str = DllComObj.FunctionReturningString()
' when leaving the scope:
' no need to free own_str,
' do I need to free dll_str?
End Sub

最佳答案

不,你不知道。 VB6 将释放它们,因为 BSTR 是其 native 字符串格式。

关于c++ - 在 VB6 中,我是否需要在使用 SysAllocString 分配的字符串上调用 SysFreeString?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14280569/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com