예제 #1
0
QT_ENSURE_STACK_ALIGNED_FOR_SSE STDMETHODIMP
QWindowsOleDropSource::QueryContinueDrag(BOOL fEscapePressed, DWORD grfKeyState)
{
    Qt::MouseButtons buttons = toQtMouseButtons(grfKeyState);

    SCODE result = S_OK;
    if (fEscapePressed || QWindowsDrag::isCanceled()) {
        result = DRAGDROP_S_CANCEL;
        buttons = Qt::NoButton;
    } else {
        if (buttons && !m_currentButtons) {
            m_currentButtons = buttons;
        } else if (!(m_currentButtons & buttons)) { // Button changed: Complete Drop operation.
            result = DRAGDROP_S_DROP;
        }
    }

    switch (result) {
        case DRAGDROP_S_DROP:
        case DRAGDROP_S_CANCEL:
            QGuiApplicationPrivate::modifier_buttons = toQtKeyboardModifiers(grfKeyState);
            QGuiApplicationPrivate::mouse_buttons = buttons;
            m_currentButtons = Qt::NoButton;
            break;

        default:
            QGuiApplication::processEvents();
            break;
    }

    if (QWindowsContext::verbose > 1 || result != S_OK) {
        qCDebug(lcQpaMime) << __FUNCTION__ << "fEscapePressed=" << fEscapePressed
            << "grfKeyState=" << grfKeyState << "buttons" << m_currentButtons
            << "returns 0x" << hex << int(result) << dec;
    }
    return ResultFromScode(result);
}
예제 #2
0
파일: ddecnvrt.cpp 프로젝트: mingpen/OpenNT
FARINTERNAL	UtGetHMFPICTFromMSDrawNativeStm
	(LPSTREAM pstm,	DWORD dwSize, HANDLE FAR* lphdata)
{
	HRESULT		error;
	WORD		mfp[3]; // mm, xExt, yExt
	HMETAFILE	hMF = NULL;
	
	*lphdata = NULL;
	
	if (error = pstm->Read(mfp, sizeof(mfp), NULL))
		return error;
	
	dwSize -= sizeof(mfp);

	if (error = UtGetHMFFromMFStm(pstm, dwSize, FALSE, (void **)&hMF))
		return error;
		
	AssertSz(mfp[0] == MM_ANISOTROPIC, "invalid map mode in MsDraw native data");
	
	if (*lphdata = UtGetHMFPICT(hMF, TRUE, (int) mfp[1], (int) mfp[2]))
		return NOERROR;

	return ResultFromScode(E_OUTOFMEMORY);	
}
예제 #3
0
UINT tOleHandler::Create(LPVOID pvType)
    {
    HRESULT             hr;
    LPUNKNOWN           pObj;
    UINT                uRet=CREATE_GRAPHICONLY;
    DWORD       dwMode=STGM_READWRITE
                    | STGM_SHARE_EXCLUSIVE
                    | STGM_DELETEONRELEASE;


    IPersistStorage *persist_storage = NULL;

    StgCreateDocfile(NULL, dwMode, 0, &m_pIStorage);

    if(m_pIStorage == NULL)
      return CREATE_FAILED;

    if (NULL==pvType)
        return CREATE_FAILED;

    hr=ResultFromScode(E_FAIL);

    Open(NULL);

    //CHAPTER24MOD
    /*
     * The OLE Control specifications mention that a
     * a control might implement IPersistStream[Init]
     * instead of IPersistStorage.  In that case you
     * cannot use OleCreate on a control but must rather
     * use CoCreateInstance since OleCreate assumes
     * that IPersistStorage is available.  With a control,
     * you would have to create the object first, then
     * check if OLEMISC_SETCLIENTSITEFIRST is set, then
     * send it your IOleClientSite first.  Then you check
     * for IPersistStorage and failing that, try
     * IPersistStream[Init].
     *
     * For simplicity we'll assume storage-based
     * controls in this sample.
     */
    //End CHAPTER24MOD

    hr = CoCreateInstance(*((LPCLSID)pvType), NULL,
      CLSCTX_ALL, IID_IUnknown, (LPVOID *)&pObj);

    if(FAILED(hr))
      return CREATE_FAILED;

    if(pObj->QueryInterface(IID_IPersistStorage, (void **) &persist_storage) != S_OK)
      return CREATE_FAILED;

    //We need an IOleObject most of the time, so get one here.
    m_pIOleObject=NULL;
    hr = pObj->QueryInterface(IID_IOleObject, (LPVOID*)&m_pIOleObject);

    if(FAILED(hr))
      return CREATE_FAILED;

    // seta o client site
    m_pIOleObject->SetClientSite(m_pImpIOleClientSite);

    // inicializa o objeto
    hr = persist_storage->InitNew(m_pIStorage);

    if(FAILED(hr))
      return CREATE_FAILED;


    //We don't get the size if PatronObject data was seen already.
    if (!ObjectInitialize(pObj))
        {
        return CREATE_FAILED;
        }

    SIZEL   szl;

    hr=ResultFromScode(E_FAIL);

    CalcNaturalSize();

    //CHAPTER24MOD
    //Make sure this happens
    /*if ((OLEMISC_ACTIVATEWHENVISIBLE & m_grfMisc))
        Activate(OLEIVERB_INPLACEACTIVATE, NULL);*/
    //End CHAPTER24MOD

    return uRet;
    }
예제 #4
0
STDMETHODIMP CDataObject::EnumDAdvise(LPENUMSTATDATA FAR* /*ppenumAdvise*/) {
	return ResultFromScode(OLE_E_ADVISENOTSUPPORTED);
}
예제 #5
0
STDMETHODIMP CDataObject::DAdvise(FORMATETC * /*pFormatetc*/, DWORD /*advf*/, LPADVISESINK /*pAdvSink*/, DWORD * /*pdwConnection*/) {
	return ResultFromScode(OLE_E_ADVISENOTSUPPORTED);
}
예제 #6
0
STDMETHODIMP CDataObject::GetCanonicalFormatEtc(LPFORMATETC /*pformatetc*/, LPFORMATETC pformatetcOut) {
	pformatetcOut->ptd = NULL;
	return ResultFromScode(E_NOTIMPL);
}
예제 #7
0
STDMETHODIMP CDataObject::GetData(LPFORMATETC pformatetc, LPSTGMEDIUM pmedium) {
	pmedium->tymed = 0;
	pmedium->pUnkForRelease = NULL;
	pmedium->hGlobal = NULL;

	//pformatetc->lindex == -1
	//pformatetc->ptd == NULL
	//pformatetc->dwAspect == DVASPECT_CONTENT

	if (pformatetc->cfFormat == m_filedescriptorID && pformatetc->tymed & TYMED_HGLOBAL) {


		int files = m_dataWindow->GetNrFiles();
		if (files <= 0)
			return ResultFromScode(E_FAIL);	//TODO: not really nice error code

		HGLOBAL globalFGD = GlobalAlloc(GMEM_MOVEABLE, sizeof(FILEGROUPDESCRIPTOR) + (files-1)*sizeof(FILEDESCRIPTOR));
		if (globalFGD == NULL)
			return ResultFromScode(E_OUTOFMEMORY);

		FILEGROUPDESCRIPTOR * fgd = (FILEGROUPDESCRIPTOR*)GlobalLock(globalFGD);
		ZeroMemory(fgd, sizeof(FILEGROUPDESCRIPTOR) + (files-1)*sizeof(FILEDESCRIPTOR));

		fgd->cItems = files;
		for(int i = 0; i < files; i++) {
			int fdres = m_dataWindow->GetFileDescriptor(&(fgd->fgd[i]), i);
			if (fdres == -1) {
				GlobalUnlock(globalFGD);
				GlobalFree(globalFGD);
				return ResultFromScode(E_FAIL);	//TODO: not really nice error code
			}
		}

		GlobalUnlock(globalFGD);
		pmedium->hGlobal = globalFGD;
		pmedium->tymed = TYMED_HGLOBAL;
		return ResultFromScode(S_OK);
	} else if (pformatetc->cfFormat == m_filecontentsID && pformatetc->tymed & TYMED_ISTREAM) {
		int index = (int)pformatetc->lindex;
		if (index >= m_dataWindow->GetNrFiles())
			return ResultFromScode(E_INVALIDARG);

		FILEDESCRIPTOR fd;
		int fdres = m_dataWindow->GetFileDescriptor(&fd, index);
		if (fdres == -1)
			return ResultFromScode(E_FAIL);	//TODO: not really nice error code

		CStreamData * stream = new CStreamData(&fd);
		if (!stream)
			return ResultFromScode(E_OUTOFMEMORY);

		pmedium->pstm = stream;
		pmedium->tymed = TYMED_ISTREAM;

		m_dataWindow->StreamData(stream, index);

		return ResultFromScode(S_OK);
	} else {
		return ResultFromScode(DATA_E_FORMATETC);
	}

	return ResultFromScode(S_OK);
}
예제 #8
0
// CImpIAccessor::CreateAccessor -----------------------------------------
//
// @mfunc Creates a set of bindings that can be used to send data
// to or retrieve data from the data cache.
//
// @rdesc HRESULT
//      @flag S_OK                      | Method Succeeded
//      @flag E_FAIL                    | Provider specific Error
//      @flag E_INVALIDARG              | pHAccessor was NULL, dwAccessorFlags was
//                                        invalid, or cBindings was not 0 and
//                                        rgBindings was NULL
//      @flag E_OUTOFMEMORY             | Out of Memory
//      @flag DB_E_ERRORSOCCURRED		| dwBindPart in an rgBindings element was invalid, OR
//									    | Column number specified was out of range, OR
//										| Requested coercion is not supported.
//      @flag OTHER                     | Other HRESULTs returned by called functions
//
STDMETHODIMP CImpIAccessor::CreateAccessor
    (
    DBACCESSORFLAGS dwAccessorFlags,
    DBCOUNTITEM     cBindings,      //@parm IN | Number of Bindings
    const DBBINDING rgBindings[],   //@parm IN | Array of DBBINDINGS
    DBLENGTH        cbRowSize,      //@parm IN | Number of bytes in consumer's buffer
    HACCESSOR*      phAccessor,     //@parm OUT | Accessor Handle
	DBBINDSTATUS	rgStatus[]		//@parm OUT	| Binding status
    )
{
    PACCESSOR   pAccessor;
    HACCESSOR   hAccessor;
    DBCOUNTITEM cBind;
    DBORDINAL   cCols;
    HRESULT     hr;


    // Check Parameters
    if( (cBindings && !rgBindings) || (phAccessor == NULL) )
        return ResultFromScode( E_INVALIDARG );

    // init out params
    *phAccessor = NULL;

	// Check if we have a correct accessor type
    if ( dwAccessorFlags & DBACCESSOR_PASSBYREF )
        return ResultFromScode( DB_E_BYREFACCESSORNOTSUPPORTED );

	// Only allow DBACCESSOR_ROWDATA and DBACCESSOR_OPTIMIZED
    if ( (dwAccessorFlags & ~DBACCESSOR_OPTIMIZED ) != DBACCESSOR_ROWDATA )
        return ResultFromScode( DB_E_BADACCESSORFLAGS );

	// Check for NULL Accessor on the Command Object
	// Also check for NULL Accessor on a read only rowset
	if( (m_pObj->GetBaseObjectType() == BOT_COMMAND && !cBindings) ||
		(m_pObj->GetBaseObjectType() == BOT_ROWSET  && !cBindings && !((CRowset *)m_pObj)->SupportIRowsetChange()) )
		return ResultFromScode( DB_E_NULLACCESSORNOTSUPPORTED );

	// Check for Optimized Accessor on the Rowset Object after Fetch
	if( (dwAccessorFlags & DBACCESSOR_OPTIMIZED) && 
		m_pObj->GetBaseObjectType() == BOT_ROWSET && ((CRowset *)m_pObj)->m_cRows )
		return ResultFromScode( DB_E_BADACCESSORFLAGS );

	// Initialize the status array to DBBINDSTATUS_OK.
	if ( rgStatus )
		memset(rgStatus, 0x00, cBindings * sizeof(DBBINDSTATUS));

    // Check on the bindings the user gave us.
    for (cBind=0, hr=NOERROR; cBind < cBindings; cBind++)
    {
		// other binding problems forbidden by OLE-DB
        const DBTYPE currType = rgBindings[cBind].wType;
        const DBTYPE currTypePtr = currType &
        					(DBTYPE_BYREF|DBTYPE_ARRAY|DBTYPE_VECTOR);
		const DBTYPE currTypeBase = currType & 
							~(DBTYPE_BYREF|DBTYPE_ARRAY|DBTYPE_VECTOR);
        const DWORD  currFlags = rgBindings[cBind].dwFlags;

        cCols = rgBindings[cBind].iOrdinal;

		// Check for a Bad Ordinal
		if( m_pObj->GetBaseObjectType() == BOT_ROWSET )
		{
			// make sure column number is in range
			if ( !(0 < cCols && cCols <= ((CRowset *) m_pObj)->m_cCols) )
			{
				// Set Bind status to DBBINDSTATUS_BADORDINAL
				hr = ResultFromScode( DB_E_ERRORSOCCURRED );
				if ( rgStatus )
					rgStatus[cBind] = DBBINDSTATUS_BADORDINAL;
				continue;
			}
		}

		// At least one of these valid parts has to be set. In SetData I assume it is the case.
        if ( !(rgBindings[cBind].dwPart & (DBPART_VALUE|DBPART_LENGTH|DBPART_STATUS)) )
		{
			// Set Bind status to DBBINDSTATUS_BADBINDINFO
            hr = ResultFromScode( DB_E_ERRORSOCCURRED );
			if ( rgStatus )
				rgStatus[cBind] = DBBINDSTATUS_BADBINDINFO;
        }

		// dwPart is something other than value, length, or status
		else if ( (rgBindings[cBind].dwPart & ~(DBPART_VALUE|DBPART_LENGTH|DBPART_STATUS)) )
		{
			// Set Bind status to DBBINDSTATUS_BADBINDINFO
            hr = ResultFromScode( DB_E_ERRORSOCCURRED );
			if ( rgStatus )
				rgStatus[cBind] = DBBINDSTATUS_BADBINDINFO;
        }

		// wType was DBTYPE_EMPTY or DBTYPE_NULL
		else if ( (currType==DBTYPE_EMPTY || currType==DBTYPE_NULL) )
		{
			// Set Bind status to DBBINDSTATUS_BADBINDINFO
            hr = ResultFromScode( DB_E_ERRORSOCCURRED );
			if ( rgStatus )
				rgStatus[cBind] = DBBINDSTATUS_BADBINDINFO;
        }

		// wType was DBTYPE_BYREF or'ed with DBTYPE_EMPTY, NULL, or RESERVED
		else if ( ((currType & DBTYPE_BYREF) && 
			  (currTypeBase == DBTYPE_EMPTY || currTypeBase == DBTYPE_NULL || 
			   currType & DBTYPE_RESERVED)) )
		{
			// Set Bind status to DBBINDSTATUS_BADBINDINFO
            hr = ResultFromScode( DB_E_ERRORSOCCURRED );
			if ( rgStatus )
				rgStatus[cBind] = DBBINDSTATUS_BADBINDINFO;
        }

		// dwFlags was DBBINDFLAG_HTML and the type was not a String
		else if ( currFlags && (currFlags != DBBINDFLAG_HTML || 
				 (currTypeBase != DBTYPE_STR  &&
				  currTypeBase != DBTYPE_WSTR &&
				  currTypeBase != DBTYPE_BSTR)) )
		{
			// Set Bind status to DBBINDSTATUS_BADBINDINFO
            hr = ResultFromScode( DB_E_ERRORSOCCURRED );
			if ( rgStatus )
				rgStatus[cBind] = DBBINDSTATUS_BADBINDINFO;
        }

		// wType was used with more than one type indicators
		else if ( !(currTypePtr == 0 || currTypePtr == DBTYPE_BYREF ||
				currTypePtr == DBTYPE_ARRAY || currTypePtr == DBTYPE_VECTOR) )
		{
			// Set Bind status to DBBINDSTATUS_BADBINDINFO
            hr = ResultFromScode( DB_E_ERRORSOCCURRED );
			if ( rgStatus )
				rgStatus[cBind] = DBBINDSTATUS_BADBINDINFO;
        }

		// wType was a non pointer type with provider owned memory
		else if ( !currTypePtr && 
			 rgBindings[cBind].dwMemOwner==DBMEMOWNER_PROVIDEROWNED )
		{
			// Set Bind status to DBBINDSTATUS_BADBINDINFO
            hr = ResultFromScode( DB_E_ERRORSOCCURRED );
			if ( rgStatus )
				rgStatus[cBind] = DBBINDSTATUS_BADBINDINFO;
        }

		// we only support client owned memory
		else if ( rgBindings[cBind].dwMemOwner != DBMEMOWNER_CLIENTOWNED )
		{
			// Set Bind status to DBBINDSTATUS_BADBINDINFO
            hr = ResultFromScode( DB_E_ERRORSOCCURRED );
			if ( rgStatus )
				rgStatus[cBind] = DBBINDSTATUS_BADBINDINFO;
        }
    }

    // Any errors amongst those checks?
    if (hr != NOERROR)
    {
        return hr;
    }

    // Make a copy of the client's binding array, and the type of binding.
    pAccessor = (ACCESSOR *) new BYTE[sizeof( ACCESSOR ) + (cBindings - 1) *sizeof( DBBINDING )];
    if ( pAccessor == NULL )
        return ResultFromScode( E_OUTOFMEMORY );

    // We store a ptr to the newly created variable-sized ACCESSOR.
    // We have an array of ptrs (to ACCESSOR's).
    // The handle is the index into the array of ptrs.
    // The InsertIntoExtBuffer function appends to the end of the array.
    assert( m_pextbufferAccessor );
    hr = m_pextbufferAccessor->InsertIntoExtBuffer(&pAccessor, hAccessor);
    if ( FAILED( hr ) )
	{
        SAFE_DELETE( pAccessor );
        return ResultFromScode( E_OUTOFMEMORY );
	}
    assert( hAccessor );

    // Copy the client's bindings into the ACCESSOR.
    pAccessor->dwAccessorFlags	= dwAccessorFlags;
    pAccessor->cBindings		= cBindings;
    pAccessor->cRef				= 1;		// Establish Reference count.
	
	memcpy( &(pAccessor->rgBindings[0]), &rgBindings[0], cBindings*sizeof( DBBINDING ));

    // fill out-param and return
    *phAccessor = hAccessor;
    return ResultFromScode( S_OK );
}
예제 #9
0
STDMETHODIMP tDispatch::GetTypeInfo(UINT itinfo
    , LCID lcid, ITypeInfo **pptInfo)
    {
    *pptInfo=NULL;
    return ResultFromScode(E_NOTIMPL);
    }
예제 #10
0
//---------------------------------------------------------------------------
// CImpICommandText::Execute 
//
// @mfunc Execute the command.  But before execution, it sets the ODBC
// statement and connection options based on the current properties.
//
// @rdesc Status of Execution
//		@flag S_OK | Execution succeeded
//		@flag E_INVALIDARG | Invalid parameter passed in.
//		@flag E_FAIL | Provider specific error
//		@flag E_OUTOFMEMORY | Not enough resources
//		@flag E_NOINTERFACE | RIID specified was not supported
//		@flag DB_E_NOCOMMAND | No Text or Tree set
//		@flag DB_E_INTERFACECONFLICT | Interface conflict with previous properties
// 		@flag OTHER	| other result codes returned by called functions.
//
STDMETHODIMP CImpICommandText::Execute
	(
	IUnknown*		pUnkOuter,		//@parm IN | Outer Unknown
	REFIID			riid,			//@parm IN | Interface ID of the interface being queried for.
	DBPARAMS*		pParams,		//@parm INOUT | Parameter Array
	DBROWCOUNT*		pcRowsAffected,	//@parm OUT | count of rows affected by command
	IUnknown**		ppRowset		//@parm OUT | Pointer to interface that was instantiated     
	)
{
	HRESULT		hr, hrProp = S_OK;
	UDWORD		dwFlags = 0;	
	UDWORD		dwStatus=0;
	ULONG		cPropSets = 0;
	ULONG		ul;
	ULONG		ul2;
	DBPROPSET	*rgPropSets = NULL;
	const IID*	pIID = &IID_ICommand;

    CFileIO*    pFileio = NULL;
    CRowset*    pRowset = NULL;

	BOOL		fCreateRowObject = FALSE;
	DBCOUNTITEM	cRowsObtained = 0;
	HROW *		phRow = NULL;
	IRowset *	pIRowset = NULL;
	IGetRow *	pIGetRow = NULL;

	assert( m_pObj->m_pUtilProp );

	// Initialize Return Buffers
	if( ppRowset )
		*ppRowset = NULL;
	
	if( pcRowsAffected )
		*pcRowsAffected = -1;
	
	if( riid != IID_NULL && !ppRowset )
		return ResultFromScode( E_INVALIDARG );

	// Only 1 ParamSet if ppRowset is non-Null
	if( pParams && (pParams->cParamSets > 1) && ppRowset )
		return ResultFromScode( E_INVALIDARG );

	// Check that a command has been set
	if( !m_pObj->IsCommandSet() )
		return DB_E_NOCOMMAND;

	// We do not allow the riid to be anything other than IID_IUnknown for aggregation
	if( pUnkOuter && riid != IID_IUnknown )
		return ResultFromScode( DB_E_NOAGGREGATION );

	// Set Status
	m_pObj->m_dwStatus |= CMD_EXECUTING;

	// Check to see if IID_IOpenRowset is calling Execute to 
	// open a rowset.
	if( m_pObj->m_guidImpersonate != GUID_NULL ) 
	{		
		assert(m_pObj->m_guidImpersonate == IID_IOpenRowset);
		pIID = &m_pObj->m_guidImpersonate;
	}

	hr = m_pObj->m_pUtilProp->GetProperties(
					PROPSET_ROWSET,
					0,
					NULL,
					&cPropSets,
					&rgPropSets);

	if( hr != S_OK )
	{
		// The only valid reason to fail is out of memory case
		assert( hr == E_OUTOFMEMORY );
		goto exit;
	}

	// Traverse the properties to see if a ROW object is requested.
	for(ul=0;ul<cPropSets; ul++)
	{
		for(ul2=0;ul2<rgPropSets[ul].cProperties; ul2++)
		{			
			// Check if a row object was requested.
			// DBPROP_IRow, DBPROP_IRowChange, and DBPROP_IRowSchemaChange indicate
			// that a ROW object is desired.
			// Sample Provider does not support IRowSchemaChange so no need to check for that 
			// property
			if( (rgPropSets[ul].rgProperties[ul2].dwPropertyID == DBPROP_IRow ||
				 rgPropSets[ul].rgProperties[ul2].dwPropertyID == DBPROP_IRowChange) &&
				rgPropSets[ul].rgProperties[ul2].dwStatus == DBPROPSTATUS_OK &&
				V_BOOL(&rgPropSets[ul].rgProperties[ul2].vValue) == VARIANT_TRUE )				
				fCreateRowObject = TRUE;				
		}
	}
  
	//Try to open the file...
	if(FAILED(hr = m_pObj->m_pCSession->m_pCDataSource->OpenFile(m_pObj->m_strCmdText, &pFileio)))
		goto exit;

    // open and initialize a rowset\cursor object
    pRowset = new CRowset( fCreateRowObject ? NULL : pUnkOuter );
    if (!pRowset)
	{
        SAFE_DELETE( pFileio );
        hr = E_OUTOFMEMORY;
		goto exit;
	}

	// Initialize the rowset\cursor.
    // For now, since don't yet support "settable" properties, so no properties to pass.
    // The rowset will always create all of its interfaces.
    // This is all-or-nothing.

	//Assign creator pointer. Used to keep track of open rowsets
    pRowset->m_pCreator = m_pObj;     
	pRowset->m_pCreator->m_pUnkOuter->AddRef();

    if( !pRowset->FInit(
						pFileio,
						(*pIID == IID_IOpenRowset) ? (CBaseObj *) m_pObj->m_pCSession : (CBaseObj *) m_pObj,
						m_pObj->m_strCmdText,
						m_pObj->m_pCSession->m_pCDataSource->GetFilePath()
						) )
	{
        SAFE_DELETE( pRowset );
        hr = DB_E_NOTABLE;
		goto exit;
	}

	// set the properties
	if ( cPropSets )
		hr = pRowset->GetCUtilProp()->SetProperties(PROPSET_ROWSET, cPropSets, rgPropSets);
	
	// If all the properties set were OPTIONAL then we return
	// DB_S_ERRORSOCCURRED and continue.
	for(ul=0;ul<cPropSets; ul++)
	{
		for(ul2=0;ul2<rgPropSets[ul].cProperties; ul2++)
		{
			// Check for a required property that failed, if found, we must return
			// DB_E_ERRORSOCCURRED
			if( (rgPropSets[ul].rgProperties[ul2].dwStatus != DBPROPSTATUS_OK) &&
				(rgPropSets[ul].rgProperties[ul2].dwOptions != DBPROPOPTIONS_OPTIONAL) )
			{
					SAFE_DELETE( pRowset );
					hr = DB_E_ERRORSOCCURRED;
					goto exit;
			}					
		}
	}

	// Optional property failure is still a success
	if( hr == DB_E_ERRORSOCCURRED )
		hrProp = DB_S_ERRORSOCCURRED;	

	// if properties failed or ppRowset NULL
	if( (FAILED(hr) && (hrProp==S_OK)) || 
		(!ppRowset) )
    {
        SAFE_DELETE( pRowset );
		goto exit;
    }

    // get requested interface pointer on rowset\cursor
	if( fCreateRowObject || riid == IID_IRow || riid == IID_IRowChange )
	{
		hr = E_FAIL;

		if( FAILED(pRowset->QueryInterface(IID_IRowset, (LPVOID *)&pIRowset)) )
			goto exit;

		if( FAILED(pIRowset->GetNextRows(DB_NULL_HCHAPTER, 0, 1, &cRowsObtained, &phRow)) )
			goto exit;

		assert( cRowsObtained == 1);
		if( FAILED(pRowset->QueryInterface(IID_IGetRow, (LPVOID *)&pIGetRow)) )
			goto exit;

		if( FAILED(hr = pIGetRow->GetRowFromHROW(pUnkOuter, phRow[0], riid, ppRowset)) )
			goto exit;

		// Sample Provider does not support selection using a critera.
		// Hence, DB_S_NOTSINGLETON is reported simply if the target file
		// contains more than one row.
		if( pRowset->GetFileObj()->GetRowCnt() > 1 )
			hr = DB_S_NOTSINGLETON;
		else
			hr = S_OK;
	}
	else
	{
		hr = pRowset->QueryInterface( riid, (void **) ppRowset );
		if( FAILED(hr) )
		{
			// Special case IID_NULL
			if( riid == IID_NULL )
				hr = S_OK;

			SAFE_DELETE( pRowset );
			goto exit;
		}
	}

	if (SUCCEEDED(hr))
		m_pObj->IncrementOpenRowsets();

	SAFE_RELEASE(pIRowset);
	SAFE_RELEASE(pIGetRow);

exit:

	if( FAILED(hr) )
		SAFE_DELETE(pRowset);		

	// Free the RowHandle
	SAFE_FREE(phRow);

	// Exiting the execution state
	m_pObj->m_dwStatus &= ~CMD_EXECUTING;

	for (ul=0; ul < cPropSets; ul++)
		SAFE_FREE(rgPropSets[ul].rgProperties);

	SAFE_FREE(rgPropSets);

	return hr;
}
예제 #11
0
STDAPI DllUnregisterServer(void) {
    AFX_MANAGE_STATE(_afxModuleAddrThis);
    if (!COleObjectFactoryEx::UpdateRegistryAll(FALSE))
        return ResultFromScode(SELFREG_E_CLASS);
    return NOERROR;
}
예제 #12
0
STDMETHODIMP CImpIDispatch::GetIDsOfNames(
			/* [in] */ REFIID riid,
            /* [size_is][in] */ OLECHAR** rgszNames,
            /* [in] */ UINT cNames,
            /* [in] */ LCID lcid,
            /* [size_is][out] */ DISPID* rgDispId)
{
	HRESULT		hr		= NOERROR;
	UINT		i		= 0;
	CString		cszName	= rgszNames[i];
	for(i=0; i<cNames; ++i)
	{
		if(cszName == cszCB_IsOurCustomBrowser)
		{
			rgDispId[i] = DISPID_CB_IsOurCustomBrowser;
		}
		/**************************主对话框操作**************************************/
		else if(cszName == csCPP_Close)
		{
			rgDispId[i] = DISPID_CB_Close;
		}
		else if (cszName == csCPP_MoveMianDlg)
		{
			rgDispId[i] = DISPID_CB_MoveMianDlg;
		}
		else if (cszName == csCPP_MinDlg)
		{
			rgDispId[i] = DISPID_CB_MinDlg;
		}
		/*******************************联系人模块操作*****************************/
		else if (cszName == csCPP_OnRequestContactData)
		{
			rgDispId[i] = DISPID_CB_RequestContactData;
		}
		else if (cszName == csCPP_OnRequestRfreshContactData)
		{
			rgDispId[i] = DISPID_CB_RequestRfreshContactData;
		}
		else if (cszName == csCPP_OnRequestAddContactData)
		{
			rgDispId[i] = DISPID_CB_RequestAddContactData;
		}
		else if (cszName == csCPP_OnRequestAddContactFile)
		{
			rgDispId[i] = DISPID_CB_RequestAddContactFile;
		}
		else if (cszName == csCPP_OnRequestDeletContactData)
		{
			rgDispId[i] = DISPID_CB_RequestDeleteContactData;
		}
		else if (cszName == csCPP_OnRequestBackUpContactData)
		{
			rgDispId[i] = DISPID_CB_RequestBackUpContactData;
		}
		else if (cszName == csCPP_OnRequestEditContactData)
		{
			rgDispId[i] = DISPID_CB_RequestEditContactData;
		}
		else if (cszName == csCPP_OnRequestAddGroupData)
		{
			rgDispId[i] = DISPID_CB_RequestAddGroupData;
		}
		else if (cszName == csCPP_OnRequestGroupData)
		{
			rgDispId[i] = DISPID_CB_RequestGroupData;
		}
		else if (cszName == csCPP_OnRequestDeleteGroupData)
		{
			rgDispId[i] = DISPID_CB_RequestDeleteGroupData;
		}
		else if (cszName == csCPP_OnRequestEditGroupData)
		{
			rgDispId[i] = DISPID_CB_RequestEditGroupData;
		}
		/******************************短信模块操作************************/
		else if (cszName == csCPP_OnRequestSmsData)
		{
			rgDispId[i] = DISPID_CB_RequestSmsData;
		}
		else if (cszName == csCPP_OnRequestDeleteSmsData)
		{
			rgDispId[i] = DISPID_CB_RequestDeleteSmsData;
		}
		else if (cszName == csCPP_OnRequestSendSms)
		{
			rgDispId[i] = DISPID_CB_RequestSendSms;
		}
		/****************************文件管理模块操作**********************/
		else
		{
			// One or more are unknown so set the return code accordingly
			hr = ResultFromScode(DISP_E_UNKNOWNNAME);
			rgDispId[i] = DISPID_UNKNOWN;
		}
	}
	return hr;
}
예제 #13
0
파일: malloc.c 프로젝트: mingpen/OpenNT
LPMALLOC SHGetTaskAllocator(HRESULT *phres)
{
    HRESULT hres = NOERROR;

    //
    // Check if the task allocator is already initialized or not.
    //
    if (g_pmemTask == NULL)
    {
        //
        //  Check if OLE32 is loaded in this process or not.
        //
        HMODULE hmod = GetModuleHandle(c_szOLE32);
#ifdef DONTUSE_TASKALLOCATOR
        // We don't use OLE's task allocator if this is a low-memory machine
        // AND OLE32.DLL is retail.
        //
        // WARNING:
        //   We don't use OLE's task allocator unless OLE32.DLL is a debug
        //  version. To find it out, we call GetProcAddress of DumpMEMSTM.
        //  Note that retail version of OLE just allocate memory from
        //  the default process heap (which LocalAlloc uses).
        //
        BOOL fSlow = (GetSystemMetrics(SM_SLOWMACHINE) & 0x0002);
        if (hmod && !(fSlow && !_IsDebugOLE(hmod)))
#else
#ifdef DEBUG
        if (TRUE)
#else
        if (hmod)
#endif
#endif // DONTUSE_TASKALLOCATOR
        {
            //
            // Yes, get the task allocator from OLE.
            //
            LPFNCOGETMALLOC pfnGetMalloc;

            //
            // Bump the reference count of OLE32.DLL
            //  Notes:
            //   We don't know when we can safely call _UnloadOLE, but
            //   that's ok -- it will just stay in this process until
            //   the process terminate.
            //
            STDAPI _LoadOLE(BOOL fRegisterTargets);     // BUGBUG - BobDay - Move this into a headerfile

#ifndef WINNT

            _LoadOLE(FALSE);

#else

            //
            // On NT, if we're going to go about loading OLE we might as well
            // hand off drop targets, etc, right now. 
            //
            // BUGBUG If _LoadOLE(FALSE) is ever called before _LoadOLE(TRUE)
            // (as would be case if SHGetTaskAllocator() was called before a
            // view was openend), Ole will never be initialized.  So, we call
            // with TRUE here in case that happens.

            _LoadOLE(TRUE);

#endif

#ifdef DEBUG
            hmod = GetModuleHandle(c_szOLE32);
#endif

            pfnGetMalloc=(LPFNCOGETMALLOC)GetProcAddress(hmod, c_szCoGetMalloc);
            if (pfnGetMalloc)
            {
                hres=pfnGetMalloc(MEMCTX_TASK, &g_pmemTask);
                if (FAILED(hres))
                {
                    //
                    //  CoGetMalloc failed. It means (typically) a shell
                    // extension called SHAlloc from within LibMain before
                    // the main app calls OleInitialize().
                    //
                    DebugMsg(DM_WARNING, TEXT("sh WR - CoGetMalloc failed (%x)"), hres);
                    Assert(g_pmemTask==NULL);
                }
            }
            else
            {
                hres = ResultFromScode(E_UNEXPECTED);
            }
        }
        else
        {
            //
            // No, use the shell task allocator (which is LocalAlloc).
            //
            g_pmemTask = &c_mem;
        }
    }

    if (phres) {
        *phres = hres;
    }

    return g_pmemTask;
}
예제 #14
0
파일: ddecnvrt.cpp 프로젝트: mingpen/OpenNT
FARINTERNAL Ut10NativeStmToContentsStm
	(LPSTORAGE pstg, REFCLSID rclsid, BOOL fDeleteSrcStm)
{

	CLIPFORMAT	cfOld;
	CLIPFORMAT	cfNew;	
	LPOLESTR	lpszUserType = NULL;
	HRESULT		error;
	LPSTREAM	pstmSrc = NULL;
	LPSTREAM	pstmDst = NULL;

	
	if (error = ReadFmtUserTypeStg(pstg, &cfOld, &lpszUserType))
		return error;

	if (rclsid == CLSID_StaticDib)
		cfNew = CF_DIB;
	else if (rclsid == CLSID_StaticMetafile)
		cfNew = CF_METAFILEPICT;
	else {
		AssertSz(FALSE, "Internal Error: this routine shouldn't have been called for this class");
		return ResultFromScode(E_FAIL);
	}
	
	if (cfOld == g_cfPBrush) {
		if (cfNew != CF_DIB) {
			error = ResultFromScode(DV_E_CLIPFORMAT);			
			goto errRtn;
		}
	} else if (cfOld == g_cfMSDraw) {
		if (cfNew != CF_METAFILEPICT) {
			error = ResultFromScode(DV_E_CLIPFORMAT);			
			goto errRtn;
		}
	} else {
		// Converted to static object from some class other than PBrush or
		// MSDraw. The data must be in a proper format in the CONTENTS
		// stream.
		return NOERROR;
	}
	
	if (error = pstg->OpenStream(OLE10_NATIVE_STREAM, NULL,
						(STGM_READ|STGM_SHARE_EXCLUSIVE),
						0, &pstmSrc))
		goto errRtn;
	
	if (error = OpenOrCreateStream(pstg, OLE_CONTENTS_STREAM, &pstmDst))
		goto errRtn;
	
	DWORD dwSize;
	if (error = pstmSrc->Read(&dwSize, sizeof(DWORD), NULL))
		goto errRtn;
			
	if (cfOld == g_cfMSDraw) {
		WORD mfp[3]; // mm, xExt, yExt
	
		if (error = pstmSrc->Read(mfp, sizeof(mfp), NULL))
			goto errRtn;
		
		dwSize -= sizeof(mfp);
		
		error = UtMFStmToPlaceableMFStm(pstmSrc, dwSize,
					(LONG) mfp[1], (LONG) mfp[2], pstmDst);
		
	} else {
		// The PBrush native data format is DIB File format. So all we got to
		// do is CopyTo.
		
		ULARGE_INTEGER ularge_int;
		ULISet32(ularge_int, dwSize);
		if ((error = pstmSrc->CopyTo(pstmDst, ularge_int, NULL,
				NULL)) == NOERROR)
			StSetSize(pstmDst, 0, TRUE);		
	}
	
errRtn:
	if (pstmDst)
		pstmDst->Release();
			
	if (pstmSrc)
		pstmSrc->Release();
	
	if (error == NOERROR) {
 		error = WriteFmtUserTypeStg(pstg, cfNew, lpszUserType);

		if (fDeleteSrcStm)				
			pstg->DestroyElement(OLE10_NATIVE_STREAM);

	} else {
		pstg->DestroyElement(OLE_CONTENTS_STREAM);	
	}	
	
	if (lpszUserType)
		PubMemFree(lpszUserType);
	
	return error;
}
예제 #15
0
파일: ddecnvrt.cpp 프로젝트: mingpen/OpenNT
FARINTERNAL UtContentsStmTo10NativeStm
	(LPSTORAGE pstg, REFCLSID rclsid, BOOL fDeleteSrcStm, UINT FAR* puiStatus)
{
	CLIPFORMAT	cf;
	LPOLESTR	lpszUserType = NULL;
	HRESULT		error;
	LPSTREAM	pstmSrc = NULL;
	LPSTREAM	pstmDst = NULL;
			
	*puiStatus = NULL;
	
	if (error = ReadFmtUserTypeStg(pstg, &cf, &lpszUserType))
		return error;
		
	
	if (! ((cf == CF_DIB  && rclsid == CLSID_PBrush)
			|| (cf == CF_METAFILEPICT && rclsid == CLSID_MSDraw))) {
		error = ResultFromScode(DV_E_CLIPFORMAT);
		goto errRtn;
	}
			
	if (error = pstg->OpenStream(OLE_CONTENTS_STREAM, NULL,
						(STGM_READ|STGM_SHARE_EXCLUSIVE),
						0, &pstmSrc)) {
		*puiStatus |= CONVERT_NOSOURCE;	

		// check whether OLE10_NATIVE_STREAM exists
		if (pstg->OpenStream(OLE10_NATIVE_STREAM, NULL,
				(STGM_READ|STGM_SHARE_EXCLUSIVE), 0, &pstmDst))
			*puiStatus |= CONVERT_NODESTINATION;
		else {
			pstmDst->Release();
			pstmDst = NULL;
		}
		
		goto errRtn;
	}
	
	if (error = OpenOrCreateStream(pstg, OLE10_NATIVE_STREAM, &pstmDst)) {
		*puiStatus |= CONVERT_NODESTINATION;						
		goto errRtn;
	}
	
	if (cf == CF_METAFILEPICT)
		error = UtPlaceableMFStmToMSDrawNativeStm(pstmSrc, pstmDst);
	else
		error = UtDIBFileStmToPBrushNativeStm(pstmSrc, pstmDst);
	
errRtn:
	if (pstmDst)
		pstmDst->Release();
			
	if (pstmSrc)
		pstmSrc->Release();
	
	if (error == NOERROR) {
		LPOLESTR lpszProgId = NULL;
		ProgIDFromCLSID(rclsid, &lpszProgId);
		
		error = WriteFmtUserTypeStg(pstg,
						RegisterClipboardFormat(lpszProgId),
						lpszUserType);

		if (lpszProgId)
			delete lpszProgId;
	}
	
	if (error == NOERROR) {
		if (fDeleteSrcStm)				
			pstg->DestroyElement(OLE_CONTENTS_STREAM);
	} else {
		pstg->DestroyElement(OLE10_NATIVE_STREAM);	
	}	
	
	if (lpszUserType)
		delete lpszUserType;
	
	return error;
}
예제 #16
0
//  Remove registry entries for implemented CLSIDs.
//  As DllUnregisterServer.
HRESULT CComDll::UnregisterServer()
{
    HRESULT	hres = ResultFromScode(E_UNEXPECTED);

    //  Determine our module (dll) path and name.
    char	szModuleName[_MAX_PATH];
    DWORD	dwModuleNameLen;
	 
	dwModuleNameLen = GetModuleFileName(szModuleName, sizeof(szModuleName));
    if (dwModuleNameLen == 0)
        return hres;
    
	// Get the list of CLSIDs
    const CLSID **ppCLSIDs = GetCLSIDs();

    if (ppCLSIDs) {
        const CLSID **ppTraverse = ppCLSIDs;
        char 		  szStringKey[80];

        while (*ppTraverse)    {
			LONG	lSize;
            
			// Get the information into registry key format.
			hres = BuildRegistryCLSIDKey(**ppTraverse, szStringKey);
			if (FAILED(hres))
				break;

            // Figure out if it points to us.
            // Continue if err, as it simply may not exist.
            if (RegQueryValue(HKEY_CLASSES_ROOT, szStringKey, NULL, &lSize) == ERROR_SUCCESS && lSize != 0) {
                LPSTR	lpszValue = NULL;

                //  Allocate a buffer large enough for it.
				lpszValue = (LPSTR)CoTaskMemAlloc(lSize);
                if (!lpszValue)  {
                    hres = ResultFromScode(E_OUTOFMEMORY);
                    break;
                }

                // We do err on not being able to query the value if we got the size
                if (RegQueryValue(HKEY_CLASSES_ROOT, szStringKey, lpszValue, &lSize) != ERROR_SUCCESS) {
                    hres = ResultFromScode(E_UNEXPECTED);
					CoTaskMemFree(lpszValue);
                    break;
                }

                // Only delete if the same; ignore the case
                if (lstrcmpi(lpszValue, szModuleName) == 0) {
                    // Delete the registry key.
                    if (RegDeleteKey(HKEY_CLASSES_ROOT, szStringKey) != ERROR_SUCCESS) {
                        hres = ResultFromScode(/*SELFREG_E_CLASS*/ E_UNEXPECTED);
                        break;
                    }
                }

				// Free the buffer
				CoTaskMemFree(lpszValue);
            }

			// Get the next CLSID
            ppTraverse++;
        }

        // Only if we made it through the loop do we consider this a success
        if (*ppTraverse == NULL)
            hres = NOERROR;

        // Free off the list of CLSIDs
		CoTaskMemFree((LPVOID)ppCLSIDs);
    }

    return hres;
}
예제 #17
0
STDMETHODIMP tDispatch::Invoke(DISPID dispIDMember, REFIID riid
    , LCID lcid, unsigned short wFlags, DISPPARAMS *pDispParams
    , VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
    {
    HRESULT     hr;
    VARIANT     varResult;

    if (IID_NULL!=riid)
        return ResultFromScode(E_INVALIDARG);

    /*
     * We ignore lcid in this function.  A multilingual application
     * might use it to determine the meaning of certain parameters
     * or perhaps as an indication of how to format data like
     * time, date, and currency or any other language or locale-
     * sensitive data.
     */

    /*
     * Variable handling:  since ambient properties is just a
     * collection of singular read-only values, we don't have to
     * worry about input parameters.
     */

    /*
     * If the caller is not interested in the return value, then
     * pVarResult is NULL.  But since we're dealing with ambient
     * properties, there should always be an interest.  In any case,
     * if we're given a NULL, we'll point it to a dummy structure so
     * the rest of the code can assume that pVarResult is non-NULL.
     */
    if(NULL==pVarResult)
      pVarResult=&varResult;

    VariantInit(pVarResult);

    //The most common case is boolean, use as an initial type
    V_VT(pVarResult)=VT_BOOL;

    /*
     * Process the requested ambient property.  Anything but a
     * request for a property is invalid, so we can check that
     * before looking at the specific ID.  We can only get away
     * with this because all properties are read-only.
     */

    if (!(DISPATCH_PROPERTYGET & wFlags))
        return ResultFromScode(DISP_E_MEMBERNOTFOUND);

    hr=NOERROR;

    switch (dispIDMember)
        {
        case DISPID_AMBIENT_BACKCOLOR:
            V_I4(pVarResult)=m_pTen->m_ambientProp.getBackColor();
            V_VT(pVarResult)=VT_I4;
            break;

        case DISPID_AMBIENT_FORECOLOR:
            V_I4(pVarResult)=m_pTen->m_ambientProp.getForeColor();
            V_VT(pVarResult)=VT_I4;
            break;

        case DISPID_AMBIENT_FONT:
            /*
             * If we failed to create the font, act like we
             * don't support it.
             */
            if (!m_pTen->m_ambientProp.has_font())
                return ResultFromScode(DISP_E_MEMBERNOTFOUND);

            //The correct type is an IFontDisp pointer
            V_DISPATCH(pVarResult)=m_pTen->m_ambientProp.getFontRef();
            V_VT(pVarResult)=VT_FONT;
            break;

        case DISPID_AMBIENT_LOCALEID:
            V_I4(pVarResult)=m_pTen->m_ambientProp.getLCID();
            V_VT(pVarResult)=VT_I4;
            break;

        case DISPID_AMBIENT_USERMODE:
          V_BOOL(pVarResult)=!m_pTen->m_ambientProp.getDesignMode();
          V_VT(pVarResult) = VT_BOOL;
            break;

        case DISPID_AMBIENT_UIDEAD:
            //V_BOOL(pVarResult)=m_pTen->m_ambientProp.getUIDead();
            V_BOOL(pVarResult)=FALSE;
            V_VT(pVarResult) = VT_BOOL;

            break;

        case DISPID_AMBIENT_SUPPORTSMNEMONICS:
            V_BOOL(pVarResult)=TRUE;
            break;

        case DISPID_AMBIENT_SHOWGRABHANDLES:
            //V_BOOL(pVarResult)=m_pTen->m_ambientProp.m_fHatchHandles;
          V_BOOL(pVarResult)=FALSE;
          V_VT(pVarResult) = VT_BOOL;
            break;

        case DISPID_AMBIENT_SHOWHATCHING:
//            V_BOOL(pVarResult)=m_pTen->m_ambientProp.m_fHatchHandles;
          V_BOOL(pVarResult)=FALSE;
          V_VT(pVarResult) = VT_BOOL;
          break;

        default:
            hr=ResultFromScode(DISP_E_MEMBERNOTFOUND);
            break;
        }

    return hr;
    }
예제 #18
0
STDMETHODIMP QOleDataObject::GetCanonicalFormatEtc( FORMATETC *, FORMATETC *pformatetcOut )
{
    pformatetcOut->ptd = NULL;
    return ResultFromScode( E_NOTIMPL );
}
STDMETHODIMP OrxScriptError::QueryInterface(REFIID riid, void **ppvObj)
{
    HRESULT hResult = E_NOINTERFACE;
    OLECHAR  cIID[100];
    char    *IIDName,TrulyUnknown[]="??????";


    if (RunDestructor && logfile)
    {
        FPRINTF2(logfile,"\n");
    }
    StringFromGUID2(riid, cIID, sizeof(cIID));
    if (RunDestructor && logfile)
    {
        FPRINTF(logfile,"OrxScriptError::QueryInterface (ppvObj = %p,\n    riid = %S \n",ppvObj,cIID);
    }
    //  We should look this riid up in HKClass_Root\Interface\.... to print what it represents.  <----

    // a pointer to result storage must be supplied
    if (!ppvObj)
    {
        return ResultFromScode(E_INVALIDARG);
    }
    // set to NULL initiallly
    *ppvObj = NULL;


    if (RunDestructor && logfile)
    {
        FPRINTF2(logfile,"It is the (");
    }
    // need to supply an IUnknown pointer?
    if (IsEqualIID(riid, IID_IUnknown))
    {
        *ppvObj = (LPVOID)(IUnknown *)(IActiveScript *) this;
        if (RunDestructor && logfile)
        {
            FPRINTF3(logfile,"IUnknown");
        }
    }
    // need to supply an IActiveScriptError pointer?
    else if (IsEqualIID(riid, IID_IActiveScriptError))
    {
        *ppvObj = (LPVOID)(IActiveScriptError *) this;
        if (RunDestructor && logfile)
        {
            FPRINTF3(logfile,"IActiveScriptError");
        }
    }
    else
    {
        if (!(IIDName = NameThatInterface((OLECHAR *)&cIID[0])))
        {
            IIDName = &TrulyUnknown[0];
        }
        if (RunDestructor && logfile)
        {
            FPRINTF3(logfile,"unsupported  %s",IIDName);
        }
        if (IIDName != &TrulyUnknown[0])
        {
            free(IIDName);
        }
    }

    if (RunDestructor && logfile)
    {
        FPRINTF3(logfile,") interface.\n\n");
    }

    // on success, call AddRef()
    if (*ppvObj != NULL)
    {
        AddRef();
        hResult = NOERROR;
    }

    return hResult;
}
예제 #20
0
STDMETHODIMP QOleDataObject::SetData( FORMATETC *pfetc, STGMEDIUM *pmedium, BOOL fRelease )
{
    return ResultFromScode( E_NOTIMPL );
}
예제 #21
0
STDMETHODIMP CDropSource::GiveFeedback(DWORD /*dwEffect*/) {
	return ResultFromScode(DRAGDROP_S_USEDEFAULTCURSORS);
}
예제 #22
0
STDMETHODIMP QOleDataObject::DAdvise( FORMATETC*, DWORD, IAdviseSink *, DWORD* )
{
    return ResultFromScode( OLE_E_ADVISENOTSUPPORTED );
}
예제 #23
0
STDMETHODIMP CDataObject::GetDataHere(LPFORMATETC /*pformatetc*/, LPSTGMEDIUM /*pmedium*/) {
	return ResultFromScode(DATA_E_FORMATETC);
}
예제 #24
0
STDMETHODIMP QOleDataObject::DUnadvise( DWORD )
{
    return ResultFromScode( OLE_E_ADVISENOTSUPPORTED );
}
예제 #25
0
STDMETHODIMP CDataObject::SetData(LPFORMATETC /*pformatetc*/, STGMEDIUM * /*pmedium*/, BOOL /*fRelease*/) {
	return ResultFromScode(E_NOTIMPL);
}
예제 #26
0
STDMETHODIMP QOleDataObject::EnumDAdvise( IEnumSTATDATA ** )
{
    return ResultFromScode( OLE_E_ADVISENOTSUPPORTED );
}
예제 #27
0
STDMETHODIMP CDataObject::DUnadvise(DWORD /*dwConnection*/) {
	return ResultFromScode(OLE_E_ADVISENOTSUPPORTED);
}
예제 #28
0
파일: MACROIMP.CPP 프로젝트: hkaiser/TRiAS
STDMETHODIMP CIMacroScriptImp :: CreateScript (LPCSTR pcName)
{
return ResultFromScode(E_NOTIMPL);
}
예제 #29
0
STDMETHODIMP CContextMenuHandler::QueryContextMenu(HMENU hmenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags)
{
#ifdef DEBUG_TO_LOG_FILES
	char	tbuf[200];
	sprintf_s(tbuf,200,__FUNCTION__ ": index=%u, first=%u, last=%u, flags=%.08lX, path=%S",indexMenu,idCmdFirst,idCmdLast,uFlags,sPath.GetString());
	f_log(tbuf);
#endif

	if (CMF_DEFAULTONLY & uFlags)
		return MAKE_HRESULT(SEVERITY_SUCCESS, 0, USHORT(0));

	if (sPath.IsEmpty())
		return MAKE_HRESULT(SEVERITY_SUCCESS, 0, USHORT(0));

	m_idCmdFirst = idCmdFirst;
	DWORD lastId = idCmdFirst;

	// Synchronization
	syncAutoLock	oLock(g_oSync);			// This lock is REQUIRED to protect shared configuration access

	{
		MENUITEMINFO miSeparator;
		miSeparator.fMask = MIIM_TYPE;
		miSeparator.fType = MFT_SEPARATOR;
		InsertMenuItem(hmenu, indexMenu++, TRUE, &miSeparator);
	}

	if (g_settingsHandler->GetBehaviorSettings().shellSettings.bRunConsoleMenItem)
	{
		// get item name
		wstring sItemName = g_settingsHandler->GetInternationalizationSettings().strExplorerMenuRunItem;
		if (sItemName.size() <= 0)
			sItemName = szItemRunConsole;

		// Fill main menu first item info
		MENUITEMINFO miRunConsole;
		memset(&miRunConsole, 0, sizeof(MENUITEMINFO));
		miRunConsole.cbSize = sizeof(MENUITEMINFO);
		miRunConsole.fMask = 0;

		miRunConsole.fMask |= MIIM_ID;
		miRunConsole.wID = idCmdFirst + eMC_RunConsole;

		miRunConsole.fMask |= MIIM_TYPE;
		miRunConsole.fType = MFT_STRING;
		miRunConsole.dwTypeData = const_cast<LPTSTR>(sItemName.c_str());
		miRunConsole.cch = sItemName.size();

		miRunConsole.fMask |= MIIM_STATE;
		miRunConsole.fState = MFS_ENABLED;

		miRunConsole.fMask |= MIIM_CHECKMARKS;
		miRunConsole.hbmpChecked = (HBITMAP)LoadImage(_AtlBaseModule.GetResourceInstance(),MAKEINTRESOURCE(IDB_MENU_PICTURE),IMAGE_BITMAP,0,0,LR_LOADTRANSPARENT);
		miRunConsole.hbmpUnchecked = (HBITMAP)LoadImage(_AtlBaseModule.GetResourceInstance(),MAKEINTRESOURCE(IDB_MENU_PICTURE),IMAGE_BITMAP,0,0,LR_LOADTRANSPARENT);

		// Insert menu item
		BOOL r = InsertMenuItem(hmenu, indexMenu, TRUE, &miRunConsole);
		indexMenu++;

		lastId = idCmdFirst + eMC_RunConsole;
	}

	if (g_settingsHandler->GetBehaviorSettings().shellSettings.bPostConsoleMenItem)
	{
		// get item name
		wstring sItemName = g_settingsHandler->GetInternationalizationSettings().strExplorerMenuPostItem;
		if (sItemName.size() <= 0)
			sItemName = szItemPostConsole;

		// Fill main menu first item info
		MENUITEMINFO miPostConsole;
		memset(&miPostConsole, 0, sizeof(MENUITEMINFO));
		miPostConsole.cbSize = sizeof(MENUITEMINFO);

		miPostConsole.fMask = 0;

		miPostConsole.fMask |= MIIM_ID;
		miPostConsole.wID = idCmdFirst + eMC_PostConsole;

		miPostConsole.fMask |= MIIM_TYPE;
		miPostConsole.fType = MFT_STRING;
		miPostConsole.dwTypeData = const_cast<LPTSTR>(sItemName.c_str());
		miPostConsole.cch = sItemName.size();

		miPostConsole.fMask |= MIIM_STATE;
		miPostConsole.fState = MFS_ENABLED;

		miPostConsole.fMask |= MIIM_CHECKMARKS;
		miPostConsole.hbmpChecked = (HBITMAP)LoadImage(_AtlBaseModule.GetResourceInstance(),MAKEINTRESOURCE(IDB_MENU_PICTURE),IMAGE_BITMAP,0,0,LR_LOADTRANSPARENT);
		miPostConsole.hbmpUnchecked = (HBITMAP)LoadImage(_AtlBaseModule.GetResourceInstance(),MAKEINTRESOURCE(IDB_MENU_PICTURE),IMAGE_BITMAP,0,0,LR_LOADTRANSPARENT);

		// Insert menu item
		BOOL r = InsertMenuItem(hmenu, indexMenu, TRUE, &miPostConsole);
		indexMenu++;

		lastId = idCmdFirst + eMC_PostConsole;
	}

	if (g_settingsHandler->GetBehaviorSettings().shellSettings.bRunConsoleTabMenuItem) {
		HMENU hSubMenu = CreateMenu();
		if (!hSubMenu)
			return MAKE_HRESULT(SEVERITY_SUCCESS, 0, USHORT(0));

		// Create submenu
		for (DWORD i = 0, lim = g_vTabs.size(); i < lim; ++i) {
			wstring sTabName = g_vTabs[i]->sName;
			HBITMAP hTabIcon = g_vTabs[i]->hIconBmp;

			// Fill main menu item info
			MENUITEMINFO miRunTabConsole;
			memset(&miRunTabConsole, 0, sizeof(MENUITEMINFO));
			miRunTabConsole.cbSize = sizeof(MENUITEMINFO);
			miRunTabConsole.fMask = MIIM_STRING | MIIM_ID | (hTabIcon ? MIIM_CHECKMARKS : 0);
			miRunTabConsole.wID = idCmdFirst + eMC_RunConsoleWithTab + i;
			miRunTabConsole.dwTypeData = const_cast<LPTSTR>(sTabName.c_str());
			miRunTabConsole.cch = sTabName.size();
			if (hTabIcon)
				miRunTabConsole.hbmpChecked = miRunTabConsole.hbmpUnchecked = hTabIcon;
			// Insert menu item
			InsertMenuItem(hSubMenu, i, TRUE, &miRunTabConsole);

			lastId = miRunTabConsole.wID;
		}
		// get item name
		wstring sItemName = g_settingsHandler->GetInternationalizationSettings().strExplorerMenuRunWithItem;
		if (sItemName.size() <= 0)
			sItemName = szItemRunConsoleWithTab;

		// Fill main menu item info
		MENUITEMINFO miRunTabConsoleMenu;
		memset(&miRunTabConsoleMenu, 0, sizeof(MENUITEMINFO));
		miRunTabConsoleMenu.cbSize = sizeof(MENUITEMINFO);
		miRunTabConsoleMenu.fMask = MIIM_CHECKMARKS|MIIM_STRING|MIIM_ID|MIIM_SUBMENU;
		miRunTabConsoleMenu.wID = idCmdFirst + eMC_RunConsoleWithTabFake;
		miRunTabConsoleMenu.dwTypeData = const_cast<LPTSTR>(sItemName.c_str());
		miRunTabConsoleMenu.cch = sItemName.size();
		miRunTabConsoleMenu.hSubMenu = hSubMenu;
		miRunTabConsoleMenu.hbmpChecked = (HBITMAP)LoadImage(_AtlBaseModule.GetResourceInstance(),MAKEINTRESOURCE(IDB_MENU_PICTURE),IMAGE_BITMAP,0,0,LR_LOADTRANSPARENT);
		miRunTabConsoleMenu.hbmpUnchecked = (HBITMAP)LoadImage(_AtlBaseModule.GetResourceInstance(),MAKEINTRESOURCE(IDB_MENU_PICTURE),IMAGE_BITMAP,0,0,LR_LOADTRANSPARENT);

		// Insert menu item
		InsertMenuItem(hmenu, indexMenu++, TRUE, &miRunTabConsoleMenu);

		lastId = idCmdFirst + eMC_RunConsoleWithTab + g_vTabs.size() - 1;
	}

	if (g_settingsHandler->GetBehaviorSettings().shellSettings.bPostConsoleTabMenuItem) {
		HMENU hSubMenu = CreateMenu();
		if (!hSubMenu)
			return MAKE_HRESULT(SEVERITY_SUCCESS, 0, USHORT(0));

		// Create submenu
		for (DWORD i = 0, lim = g_vTabs.size(); i < lim; ++i) {
			wstring sTabName = g_vTabs[i]->sName;
			HBITMAP hTabIcon = g_vTabs[i]->hIconBmp;
			
			// Fill main menu item info
			MENUITEMINFO miPostTabConsole;
			memset(&miPostTabConsole, 0, sizeof(MENUITEMINFO));
			miPostTabConsole.cbSize = sizeof(MENUITEMINFO);
			miPostTabConsole.fMask = MIIM_STRING | MIIM_ID | (hTabIcon ? MIIM_CHECKMARKS : 0);
			miPostTabConsole.wID = idCmdFirst + eMC_PostConsoleWithTab + i;
			miPostTabConsole.dwTypeData = const_cast<LPTSTR>(sTabName.c_str());
			miPostTabConsole.cch = sTabName.size();
			if (hTabIcon)
				miPostTabConsole.hbmpChecked = miPostTabConsole.hbmpUnchecked = hTabIcon;
			// Insert menu item
			InsertMenuItem(hSubMenu, i, TRUE, &miPostTabConsole);

			lastId = miPostTabConsole.wID;
		}

		// get item name
		wstring sItemName = g_settingsHandler->GetInternationalizationSettings().strExplorerMenuPostWithItem;
		if (sItemName.size() <= 0)
			sItemName = szItemPostConsoleWithTab;

		// Fill main menu item info
		MENUITEMINFO miPostTabConsoleMenu;
		memset(&miPostTabConsoleMenu, 0, sizeof(MENUITEMINFO));
		miPostTabConsoleMenu.cbSize = sizeof(MENUITEMINFO);
		miPostTabConsoleMenu.fMask = MIIM_CHECKMARKS|MIIM_STRING|MIIM_ID|MIIM_SUBMENU;
		miPostTabConsoleMenu.wID = idCmdFirst + eMC_PostConsoleWithTabFake;
		miPostTabConsoleMenu.dwTypeData = const_cast<LPTSTR>(sItemName.c_str());
		miPostTabConsoleMenu.cch = sItemName.size();
		miPostTabConsoleMenu.hSubMenu = hSubMenu;
		miPostTabConsoleMenu.hbmpChecked = (HBITMAP)LoadImage(_AtlBaseModule.GetResourceInstance(),MAKEINTRESOURCE(IDB_MENU_PICTURE),IMAGE_BITMAP,0,0,LR_LOADTRANSPARENT);
		miPostTabConsoleMenu.hbmpUnchecked = (HBITMAP)LoadImage(_AtlBaseModule.GetResourceInstance(),MAKEINTRESOURCE(IDB_MENU_PICTURE),IMAGE_BITMAP,0,0,LR_LOADTRANSPARENT);
		// Insert menu item
		InsertMenuItem(hmenu, indexMenu++, TRUE, &miPostTabConsoleMenu);

		lastId = idCmdFirst + eMC_PostConsoleWithTab + g_vTabs.size() - 1;
	}

#if 0
	{
		MENUITEMINFO miSeparator;
		miSeparator.fMask = MIIM_TYPE;
		miSeparator.fType = MFT_SEPARATOR;
		InsertMenuItem(hmenu, indexMenu++, TRUE, &miSeparator);
	}
#endif

	return ResultFromScode(MAKE_SCODE(SEVERITY_SUCCESS, 0, (USHORT)(lastId - idCmdFirst + 1)));
	//return MAKE_HRESULT(SEVERITY_SUCCESS, 0, USHORT(lastId - idCmdFirst + 1));
}
예제 #30
0
파일: MACROIMP.CPP 프로젝트: hkaiser/TRiAS
STDMETHODIMP CIMacroScriptImp :: GetScript (LPCSTR pcName, LPSTR *ppcMacroText,
											ebHCODE *phCode)
{                        
	ASSERT(pcName);

CString	strMacroName = pcName;
CMacro *pM = NULL;		
CEnumMacroScripts *pEn = NULL;
		
// immer Stream öffnen und aufheben bis neues Script geoeffnet wird
	if (m_pIStream) 
		m_pIStream -> Release(); m_pIStream = NULL;
	
HRESULT hr = OpenOrCreateStream(strMacroName, &m_pIStream);
	if (FAILED(hr)) return hr; 
		
	hr = m_pMacroScripts -> GetEnum (&pEn);
	if (FAILED(hr)) return hr; 		

// pMakro -> AddRef(), wenn aufindbar !!!
	hr = pEn -> FindByName (strMacroName, &pM);
	pEn -> Release();
	if (FAILED(hr)) { 
		if (pM) pM -> Release(); return hr;
	}

	*ppcMacroText = NULL;

	if (S_FALSE == GetScode(hr)) {

// pMakro -> AddRef(), kein passendes Objekt gefunden, Schaffen des Objektes 
		
		pM = CMacro :: Create (NULL);
		if (NULL == pM) {
			if (m_pIStream) m_pIStream; m_pIStream = NULL; return ResultFromScode(E_FAIL);
		}

		pM -> GetIMacros() -> SetName(strMacroName);
// neues Macro für späteres Commit() kennzeichnen
		pM -> GetIMacros() -> SetNew(true);

// Script in Liste füllen, pMakro->AddRef(),   
		hr = m_pMacroScripts -> AddScript (strMacroName, pM);
		pM -> Release();
		if (FAILED(hr)) {
			if (m_pIStream) m_pIStream; m_pIStream = NULL; return hr;
		}

		return ResultFromScode (S_FALSE);
	
	} else {

// Makro schon vorhanden und geöffnet bei pPersistStorage -> Load()			
// liest eigentliche Daten aus PersistStream-Objekt
		hr = GetData (ppcMacroText, phCode, pM);
// von FindByName() 
		pM -> Release();

// ppcMacroText, phCode draussen freigeben
		if (FAILED(hr)) {
			if (m_pIStream) m_pIStream; m_pIStream = NULL; return hr;
		}
	}                           
	
return ResultFromScode (S_OK);
}