BSTR allocation and free
There are many allocation functions available for allocating BSTRs. BSTRs are allocated with one of SysAllocStringXXX or SysReAllocStringXXX function which is suitable by the developer. SysFreeString is one single function to free the allocated string allocated by any allocation functions.
BSTR APIs
These are the BSTR manipulation APIs.
Increases the pinning reference count for the specified string by one. | |
Allocates a new string and copies the passed string into it. | |
Takes an ANSI string as input, and returns a BSTR that contains an ANSI string. Does not perform any ANSI-to-Unicode translation. | |
Allocates a new string, copies the specified number of characters from the passed string, and appends a null-terminating character. | |
Deallocates a string allocated previously by SysAllocString, SysAllocStringByteLen, SysReAllocString, SysAllocStringLen, or SysReAllocStringLen. | |
Reallocates a previously allocated string to be the size of a second string and copies the second string into the reallocated memory. | |
Creates a new BSTR containing a specified number of characters from an old BSTR, and frees the old BSTR. | |
Decreases the pinning reference count for the specified string by one. When that count reaches 0, the memory for that string is no longer prevented from being freed. | |
Returns the length (in bytes) of a BSTR. | |
Returns the length of a BSTR. |
BSTR alloc and free code
BSTR strSample = SysAllocString(L”This is a sample BSTR”); SysFreeString(strSample);
About our authors: Team EQA
You have viewed 1 page out of 67. Your COM/DCOM learning is 0.00% complete. Login to check your learning progress.