[PATCH 4/5] d2d1: Implement RegisterEffectFromString().

Nikolay Sivov nsivov at codeweavers.com
Mon Jun 6 06:04:06 CDT 2022



On 6/6/22 13:31, Ziqing Hui wrote:
>
> On 6/6/22 4:37 PM, Nikolay Sivov wrote:
>>
>> On 6/6/22 10:35, Ziqing Hui wrote:
>>> +    size = sizeof(*property_xml) * (wcslen(property_xml) + 1);
>>> +    hglobal = GlobalAlloc(0, size);
>>> +    data = GlobalLock(hglobal);
>>> +    memcpy(data, property_xml, size);
>>> +    GlobalUnlock(hglobal);
>>> +
>>> +    if (FAILED(hr = CreateStreamOnHGlobal(hglobal, TRUE, &stream)))
>>> +        return hr;
>> Seems easier to write whole string in a stream, and seek back.
>>
> I'm not familiar with IStream interface... I'm not pretty sure how to do this.
> Do I still use CreateStreamOnHGlobal() to create a stream?
> Do you mean I should create a stream first. And then use IStream_Write() to write the string to it, then seek back?
>
Yes, create it with a null memory handle, Write, and Seek() back to the 
beginning. Another option is to have some wrapper that implements Read() 
and save on additional allocations, but it's more code that we don't need.



More information about the wine-devel mailing list