C
Charles Law
Could anyone please tell me what is wrong with the code below:
STDMETHODIMP CSimpleObj::WriteUnmanagedData(BSTR pString, IStream** ppData)
{
HRESULT hr;
hr = CreateStreamOnHGlobal(0, TRUE, ppData);
if (FAILED(hr))
return hr;
ULONG lBytesWritten;
hr = (*ppData)->Write(pString, SysStringLen(pString), &lBytesWritten);
//hr = (*ppData)->Write("This is unmanaged data.", 24, &lBytesWritten);
if (FAILED(hr))
return hr;
return S_OK;
}
The line commented out works as expected (copies the whole string). The line
above it only seems to copy one character (the first character). No doubt I
have made a trivial mistake, but please humour me.
Thanks for any help.
Charles
STDMETHODIMP CSimpleObj::WriteUnmanagedData(BSTR pString, IStream** ppData)
{
HRESULT hr;
hr = CreateStreamOnHGlobal(0, TRUE, ppData);
if (FAILED(hr))
return hr;
ULONG lBytesWritten;
hr = (*ppData)->Write(pString, SysStringLen(pString), &lBytesWritten);
//hr = (*ppData)->Write("This is unmanaged data.", 24, &lBytesWritten);
if (FAILED(hr))
return hr;
return S_OK;
}
The line commented out works as expected (copies the whole string). The line
above it only seems to copy one character (the first character). No doubt I
have made a trivial mistake, but please humour me.
Thanks for any help.
Charles