Beispiel #1
0
// die folgende Funktion ist das konkrete äquivalent für 'OleLoadFromStream' --
HRESULT CreateStringFromStream (IStream *pIStream, LPSTR lpstr, int iLen)
{
	ASSERT(pIStream);
	ASSERT(lpstr);
	ASSERT(0 < iLen);
	if (NULL == lpstr) return E_POINTER;
	if (0 == iLen) return E_INVALIDARG;

	USES_CONVERSION;

	*lpstr = '\0';

	try 
	{	// Variant liest sich selbst vom Stream
		CComVariant cv;// VariantInit()
		HRESULT hr = cv.ReadFromStream (pIStream);  
		if (FAILED(hr)) _com_issue_error(hr);
		// Richtigen Typ rausholen
		hr = cv.ChangeType (VT_BSTR);
		if (FAILED(hr)) _com_issue_error(hr);
		// Wert lesen
		CComBSTR bstr = cv.bstrVal; // SysAllocString(...
		LPSTR lpstrName = OLE2A(bstr.m_str);
		if (iLen < strlen(lpstrName)) _com_issue_error(E_INVALIDARG); 
		strcpy(lpstr, lpstrName);
		// in ~CComVariant() VariantClear()
	} // in ~CComBSTR() SysFreeString(m_str)
	catch (_com_error& e) 
	{
		return _COM_ERROR(e);
	}

	return NOERROR;
}
Beispiel #2
0
HRESULT CControlState::Load( LPSTREAM pStm )
{
   HRESULT hr = S_OK;
   CComVariant var;

   DWORD dwVer;
   READDATA( dwVer );

   // version 1 and 2 are pre-2.0 and are not backward compatible.  Ignore this data.
   if ( dwVer < 3 )
   {
      return S_FALSE;
   }

   READDATA( m_bColorSyntax );
   READDATA( m_bAllowHSplit );
   READDATA( m_bAllowVSplit );
   READDATA( m_bHScroll );
   READDATA( m_bVScroll );
   READDATA( m_bSmoothScroll );
   READDATA( m_bLineToolTips );
   READDATA( m_bShowLeftMargin );
   READDATA( m_bAllowColumnSel );
   READDATA( m_bAllowDragDrop );
   READDATA( m_bExpandTabs );
   READDATA( m_xPosHSplitter );
   READDATA( m_yPosVSplitter );
   READDATA( m_eIndentStyle );
   READDATA( m_nTabSize );
   READDATA( m_Colors );
   READDATA( m_lf );

   // dealloc old strings
   FreeStrings();

   if ( SUCCEEDED( hr = var.ReadFromStream( pStm ) ) )
   {
       m_bstrText = var.bstrVal;
       var.bstrVal = NULL;
       var.vt = VT_EMPTY;
   }
   else
      goto bail;

   if ( SUCCEEDED( hr = var.ReadFromStream( pStm ) ) )
   {
       m_bstrLang = var.bstrVal;
       var.bstrVal = NULL;
       var.vt = VT_EMPTY;
   }
   else
      goto bail;

   READDATA( m_bDisplayWhitespace );
   READDATA( m_bWantCarriageReturn );
   READDATA( m_bEnabled );
   READDATA( m_bGlobalProps );
   READDATA( m_bModified );
   READDATA( m_bOverType );
   READDATA( m_bReadOnly );
   READDATA( m_bPreserveCase );
   READDATA( m_bCaseSensitiveSearch );
   READDATA( m_bWholeWordOnly );
   READDATA( m_nMaxUndo );
   READDATA( m_bSelBounds );
   READDATA( m_bRegExp );
   READDATA( m_FontStyles );
   READDATA( m_LineNum );
   READDATA( m_bHideSel );
   READDATA( m_bNormalizeCase );
   READDATA( m_bOvertypeCaret );
   READDATA( m_nHighlightedLine );

   if ( dwVer < 4 )
      goto bail;

   READDATA( m_dwBorderStyle );

   if ( dwVer < 5 )
      goto bail;

   READDATA( m_bStealKeys );

   bail:

   return hr;
}