次の方法で共有


IDebugProperty3::GetStringCharLength

Returns the number of characters in the associated property's string.

HRESULT GetStringCharLength(
   ULONG *pLen
);
int GetStringCharLength(
   out uint pLen
);

Parameters

Parameter

Description

pLen

[out] Returns the number of characters in the property's string.

Return Value

If successful, returns S_OK; otherwise returns error code.

Remarks

Typically, this method is used as a prelude to allocating a buffer for a call to the IDebugProperty3::GetStringChars method.

Example

The following example shows how to implement this method for a CProperty object that exposes the IDebugProperty3 interface.

STDMETHODIMP CProperty::GetStringCharLength(ULONG *pLen)
{
    HRESULT hr = E_INVALIDARG;

    EVALFLAGS oldEVALFLAGS = m_EVALFLAGS;

    m_EVALFLAGS &= ~EVAL_NOFUNCEVAL;

    if (pLen)
    {
        DEBUG_PROPERTY_INFO dpInfo;
        dpInfo.bstrValue = NULL;
        ULONG ulen = 0;
        hr = GetPropertyInfo(DEBUGPROP_INFO_VALUE,10,DEFAULT_TIMEOUT,NULL,0,&dpInfo);
        if (hr == S_OK && dpInfo.bstrValue)
        {
            if (wcscmp(dpInfo.bstrValue,L"Nothing") == 0)
            {
                ulen = 0;   //VSWhidbey#64815
            }
            else
            {
                ulen = ::SysStringLen(dpInfo.bstrValue);
                if( ulen > 2 &&
                    dpInfo.bstrValue[0] == L'"' &&
                    dpInfo.bstrValue[ulen-1] == L'"')
                {                    
                    ulen = ulen > 2 ? ulen - 2 : ulen;  //remove two double quotes
                }
            }
        }
        ::SysFreeString(dpInfo.bstrValue);
        *pLen = ulen;
    }
    m_EVALFLAGS = oldEVALFLAGS;
    return hr;
}

See Also

Reference

IDebugProperty3::GetStringChars

IDebugProperty3