Exemple #1
0
STDMETHODIMP CActiveXCtrl::GetContainer(IOleContainer** ppContainer)
{
   TRACE("AX: CActiveXCtrl::GetContainer");
   if( ppContainer == NULL ) return E_POINTER;
   *ppContainer = NULL;
   HRESULT Hr = E_NOTIMPL;
   if( m_pUnkSite != NULL ) Hr = m_pUnkSite->QueryInterface(IID_IOleContainer, (LPVOID*) ppContainer);
   if( FAILED(Hr) ) Hr = QueryInterface(IID_IOleContainer, (LPVOID*) ppContainer);
   return Hr;
}
Exemple #2
0
/*
 * Initialize Global IME.
 * "atom" must be return value of RegisterClass(Ex).
 */
    void
global_ime_init(ATOM atom, HWND hWnd)
{
    IUnknown *pI;
    HRESULT hr;

    if (pIApp != NULL || pIMsg != NULL)
	return;
    OleInitialize(NULL);

    /*
     * Get interface IUnknown
     */
    hr = CoCreateInstance(CLSID_CActiveIMM, NULL, CLSCTX_SERVER,
	    IID_IUnknown, (void**)&pI);
    if (FAILED(hr) || !pI)
	return;

    /*
     * Get interface IActiveIMMApp
     */
    hr = pI->QueryInterface(IID_IActiveIMMApp, (void**)&pIApp);
    if (FAILED(hr))
	pIApp = NULL;

    /*
     * Get interface IActiveIMMMessagePumpOwner
     */
    hr = pI->QueryInterface(IID_IActiveIMMMessagePumpOwner, (void**)&pIMsg);
    if (FAILED(hr))
	pIMsg = NULL;

    if (pIApp != NULL)
    {
	pIApp->Activate(TRUE);
	pIApp->FilterClientWindows(&atom, 1);
    }
    if (pIMsg != NULL)
	pIMsg->Start();

    pI->Release();
    s_hWnd = hWnd;
}
Exemple #3
0
//---------------------------------------------------------------------------
bool __fastcall TTSSWaveContext::Start(AnsiString filename)
{
	if(FDecoder) FDecoder->Release(), FDecoder = NULL;


	HRESULT hr;
	IUnknown * decoder;

	hr = FModule->GetMediaInstance(WideString(filename).c_bstr(), &decoder);
	if(FAILED(hr))
	{
		throw Exception(filename + " は開くことができません");
	}

	hr = decoder->QueryInterface(IID_ITSSWaveDecoder, (void**)&FDecoder);
	if(FAILED(hr))
	{
		decoder->Release();
		FDecoder = NULL;
		throw Exception(filename + " のメディア・タイプは扱うことができません");
	}

	decoder->Release();

	TSSWaveFormat format;
	FDecoder->GetFormat(&format);
	if(format.dwBitsPerSample != 16)
	{
		throw Exception(filename + " は 16bit PCM に変換できないため扱うことができません");
	}
	if(format.dwChannels > 8)
	{
		throw Exception(filename + " は 9チャネル以上あるため扱うことができません");
	}
	if(format.ui64TotalSamples == 0)
	{
		throw Exception(filename + " は 総サンプル数が不明か、ゼロのため扱うことができません");
	}
	if(format.ui64TotalSamples >= 0x10000000ui64)
	{
		throw Exception(filename + " は 大きすぎるため、扱うことができません");
	}
	FChannels = format.dwChannels;
	FFrequency = format.dwSamplesPerSec;
	FBitsPerSample = 16;
	FSpeakerConfig = 0; // 現時点では常に 0 (なにか規格をつくるかも)
	FTotalSamples = (int)format.ui64TotalSamples;

	FGranuleSize = FChannels * sizeof(__int16);

//	FDecoder->SetPosition(0); /// test

	return true;
}
////////////////////////////////////////////////////////
// CBase::GetBaseInterface
//
////////////////////////////////////////////////////////
HRESULT CBase::GetBaseInterface(REFIID riid, IUnknown** ppIUnknown)
{
	if(ppIUnknown)
		*ppIUnknown = NULL;
	
	IUnknown* pBaseUnk = GetBaseObj();
	if(pBaseUnk)
		return pBaseUnk->QueryInterface(riid, (void**)ppIUnknown);

	return E_FAIL;
}
STDMETHODIMP
CConnectionPoint::GetConnectionPointContainer(IConnectionPointContainer **ppCPC)
{
  LOGCALL(("CConnectionPoint::GetConnectionPointContainer()\n"));

  // CConnectionPoint's GetOuterUnknown() returns the IUnknown of the host object.
  IUnknown* pUnkCPC = GetOuterUnknown();
  assert(pUnkCPC != NULL);

  return pUnkCPC->QueryInterface(IID_IConnectionPointContainer, (void**) ppCPC);
}
Exemple #6
0
//
// SetUsageScenario is the provider's cue that it's going to be asked for tiles
// in a subsequent call.  In this sample we have chosen to precreate the credentials 
// for the usage scenario passed in cpus instead of saving off cpus and only creating
// the credentials when we're asked to.
// This sample only handles the logon and unlock scenarios as those are the most common.
//
HRESULT CXCreProvider::SetUsageScenario(
	CREDENTIAL_PROVIDER_USAGE_SCENARIO cpus,
	DWORD dwFlags
	)
{
	HRESULT hr;

	// Create the password credential provider and query its interface for an
	// ICredentialProvider we can use. Once it's up and running, ask it about the 
	// usage scenario being provided.
	IUnknown *pUnknown = NULL;
	
	//802.1x 
	//hr = CoCreateInstance(CLSID_OnexCredentialProvider, NULL, CLSCTX_ALL, IID_PPV_ARGS(&pUnknown));

	//smart card
	//hr = CoCreateInstance(CLSID_SmartcardCredentialProvider, NULL, CLSCTX_ALL, IID_PPV_ARGS(&pUnknown));

	//username+password
	hr = CoCreateInstance(CLSID_V1PasswordCredentialProvider, NULL, CLSCTX_ALL, IID_PPV_ARGS(&pUnknown));
	if (SUCCEEDED(hr))
	{		
		hr = pUnknown->QueryInterface(IID_PPV_ARGS(&(m_pOrgProvider)));
		if (SUCCEEDED(hr))
		{
			hr = m_pOrgProvider->SetUsageScenario(cpus, dwFlags);			
			m_cpus = cpus;

			//增加窗口
			m_pEventWin = new CCmdEventWnd();
			if(NULL != m_pEventWin)
			{
				m_pEventWin->Initialize(this);
			}
		}
	}	

	if (FAILED(hr))
	{
		if (m_pOrgProvider != NULL)
		{
			m_pOrgProvider->Release();
			m_pOrgProvider = NULL;
		}

		if(NULL != m_pEventWin)
		{
			delete m_pEventWin;
			m_pEventWin = NULL;
		}
	}

	return hr;
}
Exemple #7
0
int _tmain(int argc, _TCHAR* argv[])
{
	IUnknown* pU = CreateInstance();
	IComponent *pI = NULL;
	pU->QueryInterface(IID_IComponent, (void**)&pI);
	pI->Print("testing");
	char c;
	cin >> c;
	pI->Release();
	cin >> c;
	return 0;
}
HRESULT
sbWindowsFormatter::GetVolume(BSTR           aVolumeName,
                              IVdsVolumeMF** aVolume)
{
  // Validate arguments.
  SB_WIN_ENSURE_ARG_POINTER(aVolumeName);
  SB_WIN_ENSURE_ARG_POINTER(aVolume);

  // Function variables.
  HRESULT result;

  // Return a null volume by default.
  *aVolume = NULL;

  // Get the list of software providers and set it up for auto-disposal.
  IEnumVdsObject* swProviderEnum;
  result = mVdsService->QueryProviders(VDS_QUERY_SOFTWARE_PROVIDERS,
                                       &swProviderEnum);
  SB_WIN_ENSURE_SUCCESS(result, result);
  sbAutoIUnknown autoSwProviderEnum(swProviderEnum);

  // Search each software provider for the volume.  Enumerate all software
  // providers until no more remain or until the volume is found.
  while (1) {
    // Get the next software provider and set it up for auto-disposal.  The
    // returned count will be zero when the enumeration is complete.
    IUnknown* swProviderIUnknown;
    ULONG     count;
    result = swProviderEnum->Next(1, &swProviderIUnknown, &count);
    SB_WIN_ENSURE_SUCCESS(result, result);
    if (!count)
      break;
    sbAutoIUnknown autoSwProviderIUnknown(swProviderIUnknown);

    // QI the software provider and set it up for auto-disposal.
    IVdsSwProvider* swProvider;
    result = swProviderIUnknown->QueryInterface
                                   (IID_IVdsSwProvider,
                                    reinterpret_cast<void**>(&swProvider));
    SB_WIN_ENSURE_SUCCESS(result, result);
    sbAutoIUnknown autoSwProvider(swProvider);

    // Try getting the volume from the software provider.  Return volume if
    // found.
    result = GetVolume(swProvider, aVolumeName, aVolume);
    SB_WIN_ENSURE_SUCCESS(result, result);
    if (result == S_OK)
      return S_OK;
  }

  return S_FALSE;
}
HRESULT CFormattedTextDraw::CreateTextServicesObject()
{
	HRESULT hr;
	IUnknown *spUnk;

	hr = CreateTextServices(NULL, static_cast<ITextHost*>(this), &spUnk);
	if (hr == S_OK) {
		hr = spUnk->QueryInterface(IID_ITextServices, (void**)&m_spTextServices);
		hr = spUnk->QueryInterface(IID_ITextDocument, (void**)&m_spTextDocument);
		spUnk->Release();
	}
	return hr;
}
Exemple #10
0
//-------------------------------------------------------------------------------
// Name: HrGetDoc
// Desc: Получить Документ
//-------------------------------------------------------------------------------
HRESULT COfsDhtmlEditCtrl::HrGetDoc(IHTMLDocument2 **ppDoc)
{
	HRESULT         hr = E_FAIL;
	IUnknown* lpUnk = m_pSite->GetObjectUnknown();

	if ( lpUnk != NULL )
	{
		// Request the "document" object from the MSHTML
		hr = lpUnk->QueryInterface(IID_IHTMLDocument2, (void **)ppDoc);
	}

	return hr;
}
STDMETHODIMP FWmfMediaByteStream::Invoke(IMFAsyncResult* AsyncResult)
{
	// recover read state
	IUnknown* State = NULL;
	HRESULT Result = AsyncResult->GetState(&State);
	check(SUCCEEDED(Result));

	IMFAsyncResult* CallerResult = NULL;
	Result = State->QueryInterface(IID_PPV_ARGS(&CallerResult));
	check(SUCCEEDED(Result));

	IUnknown* Unknown = NULL;
	
	if (CallerResult != NULL)
	{
		Result = CallerResult->GetObject(&Unknown);
		check(SUCCEEDED(Result));
	}

	FWmfMediaReadState* ReadState = static_cast<FWmfMediaReadState*>(Unknown);

	// perform the read
	ULONG cbRead;
	Read(ReadState->GetReadBuffer(), ReadState->GetReadBufferSize() - ReadState->GetBytesRead(), &cbRead);
	ReadState->AddBytesRead(cbRead);

	// notify caller
	if (CallerResult != NULL)
	{
		CallerResult->SetStatus(Result);
		::MFInvokeCallback(CallerResult);
	}

	// clean up
	if (CallerResult != NULL)
	{
		CallerResult->Release();
	}

	if (Unknown != NULL)
	{
		Unknown->Release();
	}

	if (State != NULL)
	{
		State->Release();
	}

	return S_OK;
}
Exemple #12
0
    void lazyInitialize()
    {
        typedef HRESULT(STDAPICALLTYPE * T_CreateTextServices)(
            IUnknown *punkOuter,
            ITextHost *pITextHost,
            IUnknown **ppUnk);

        if (!dc_)
            dc_ = ::CreateCompatibleDC(NULL);

        assert(dc_);

        if (!services_)
        {
            HMODULE rich = ::GetModuleHandle(L"Msftedit.dll");
            if (!rich)
                rich = ::LoadLibrary(L"Msftedit.dll");
            assert(rich);
            if (!rich)
            {
                BLG_ERROR << "rich edit Msftedit.dll not found";
                return;
            }

            IUnknown * pun = nullptr;
            T_CreateTextServices TCreateTextServices = (T_CreateTextServices)GetProcAddress(rich,
                "CreateTextServices");
            IID* IID_ITS = (IID*)(VOID*)GetProcAddress(rich,
                "IID_ITextServices");

            auto hr = TCreateTextServices(NULL, this, &pun);
            if (FAILED(hr))
            {
                BLG_ERROR << "rich edit CreateTextServices fail";
                return;
            }

            hr = pun->QueryInterface(*IID_ITS, (void **)&services_);
            pun->Release();
            if (FAILED(hr))
            {
                BLG_ERROR << "rich edit QueryInterface IID_ITextServices fail";
                return;
            }
            assert(services_);
            initDefaultCF();
            initDefaultPF();
            services_->OnTxInPlaceActivate(NULL);
        }

    }
HRESULT
sbWindowsFormatter::GetVolume(IVdsSwProvider* aSwProvider,
                              BSTR            aVolumeName,
                              IVdsVolumeMF**  aVolume)
{
  // Validate arguments.
  SB_WIN_ENSURE_ARG_POINTER(aSwProvider);
  SB_WIN_ENSURE_ARG_POINTER(aVolumeName);
  SB_WIN_ENSURE_ARG_POINTER(aVolume);

  // Function variables.
  HRESULT result;

  // Return a null volume by default.
  *aVolume = NULL;

  // Get the list of VDS packs and set it up for auto-disposal.
  IEnumVdsObject* packEnum;
  result = aSwProvider->QueryPacks(&packEnum);
  SB_WIN_ENSURE_SUCCESS(result, result);
  sbAutoIUnknown autoPackEnum(packEnum);

  // Search each pack for the volume.  Enumerate all packs until no more remain
  // or until the volume is found.
  while (1) {
    // Get the next pack and set it up for auto-disposal.  The returned count
    // will be zero when the enumeration is complete.
    IUnknown* packIUnknown;
    ULONG     count;
    result = packEnum->Next(1, &packIUnknown, &count);
    SB_WIN_ENSURE_SUCCESS(result, result);
    if (!count)
      break;
    sbAutoIUnknown autoPackIUnknown(packIUnknown);

    // QI the pack and set it up for auto-disposal.
    IVdsPack* pack;
    result = packIUnknown->QueryInterface(IID_IVdsPack,
                                          reinterpret_cast<void**>(&pack));
    SB_WIN_ENSURE_SUCCESS(result, result);
    sbAutoIUnknown autoPack(pack);

    // Try getting the volume from the pack.  Return volume if found.
    result = GetVolume(pack, aVolumeName, aVolume);
    SB_WIN_ENSURE_SUCCESS(result, result);
    if (result == S_OK)
      return S_OK;
  }

  return S_FALSE;
}
IFileIsInUse* CreateIFileIsInUse(const string& File)
{
	IFileIsInUse *pfiu = nullptr;
	IRunningObjectTable *prot;
	if (SUCCEEDED(GetRunningObjectTable(0, &prot)))
	{
		IMoniker *pmkFile;
		if (SUCCEEDED(CreateFileMoniker(File.data(), &pmkFile)))
		{
			IEnumMoniker *penumMk;
			if (SUCCEEDED(prot->EnumRunning(&penumMk)))
			{
				HRESULT hr = E_FAIL;
				ULONG celt;
				IMoniker *pmk;
				while (FAILED(hr) && (penumMk->Next(1, &pmk, &celt) == S_OK))
				{
					DWORD dwType;
					if (SUCCEEDED(pmk->IsSystemMoniker(&dwType)) && dwType == MKSYS_FILEMONIKER)
					{
						IMoniker *pmkPrefix;
						if (SUCCEEDED(pmkFile->CommonPrefixWith(pmk, &pmkPrefix)))
						{
							if (pmkFile->IsEqual(pmkPrefix) == S_OK)
							{
								IUnknown *punk;
								if (prot->GetObject(pmk, &punk) == S_OK)
								{
									hr = punk->QueryInterface(
#ifdef __GNUC__
										IID_IFileIsInUse, IID_PPV_ARGS_Helper(&pfiu)
#else
										IID_PPV_ARGS(&pfiu)
#endif
										);
									punk->Release();
								}
							}
							pmkPrefix->Release();
						}
					}
					pmk->Release();
				}
				penumMk->Release();
			}
			pmkFile->Release();
		}
		prot->Release();
	}
	return pfiu;
}
HRESULT MyClassFactory::CreateInstance(LPUNKNOWN pUnkOuter, REFIID riid, void** ppvObj)
{
	ATLASSERT(ppvObj);
	if (NULL == ppvObj)
	{
		return E_INVALIDARG;
	}
	*ppvObj = NULL;

	HRESULT hr = S_OK;
	IUnknown *server = NULL;
	IUnknown *inner = NULL;

	if (NULL == DataService::Instance())
	{
		return E_POINTER;
	}

	if (loClientCreate_agg(DataService::Instance().get(), (loClient**)&server, 
		pUnkOuter, &inner,
		0, &vendor, a_server_finished, NULL/*cuserid*/))
	{
		// server remove
		UL_ERROR((Log::Instance().get(), 0, "myClassFactory::loClientCreate_agg() failed"));
		hr = E_OUTOFMEMORY;
	}
	else if (pUnkOuter)
	{
		*ppvObj = (void*)inner; // aggregation requested
	}	
	else // no aggregation
	{
		hr = server->QueryInterface(riid, ppvObj); // Then 2 (if success)
		server->Release(); // Then 1 (on behalf of client) or 0 (if QI failed)
	}

	if (SUCCEEDED(hr))
	{
		loSetState(DataService::Instance().get(), (loClient*)server,
			loOP_OPERATE, (int)OPC_STATUS_RUNNING, "Finished by client");
		UL_INFO((Log::Instance().get(), 0, "OPC service is started."));
	}

#ifdef __EVAL__
	boost::shared_ptr<boost::thread> licThread(new boost::thread(LicenseTimeout)); 
#endif

	return hr;
}
Exemple #16
0
int main(int argc, char* argv[])
{
    if (argc != 3)
    {
	fprintf(stderr, "Usage : %s <sdp version> <sdp file>\n", argv[0]);
    }
    else
    {
	IUnknown* pContext = new CHXMiniCCF();
	
	if (pContext)
	{
	    pContext->AddRef();
	    
	    IHXCommonClassFactory* pCCF = 0;

	    if (HXR_OK == pContext->QueryInterface(IID_IHXCommonClassFactory,
						   (void**)&pCCF))
	    {
		IHXBuffer* pSDP = ReadSDPFile(pCCF, argv[2]);

		if (pSDP)
		{
		    if (HXR_OK != Parse(pContext, strtoul(argv[1], 0, 10), 
					pSDP))
		    {
			fprintf(stderr, "Failed to parse SDP\n", argv[1]);
		    }

		    pSDP->Release();
		    pSDP = 0;
		}
		else
		{
		    fprintf(stderr, "Failed to read SDP file '%s'\n", argv[2]);
		}

		pCCF->Release();
		pCCF = 0;
	    }
	    	    
	    pContext->Release();
	    pContext = 0;
	}
	
    }

    return 0;
}
HRESULT CreateMediaSource(
    const WCHAR *sURL,  // The URL of the file to open.
    IMFMediaSource** ppMediaSource // Receives a pointer to the media source.
    )
{
    if (!sURL)
    {
        return E_INVALIDARG;
    }

    if (!ppMediaSource)
    {
        return E_POINTER;
    }

    HRESULT hr = S_OK;
    
    MF_OBJECT_TYPE ObjectType = MF_OBJECT_INVALID;

    IMFSourceResolver* pSourceResolver = NULL;
    IUnknown* pUnkSource = NULL;

    // Create the source resolver.
    hr = MFCreateSourceResolver(&pSourceResolver);


    // Use the source resolver to create the media source.
    
    if (SUCCEEDED(hr))
    {
        hr = pSourceResolver->CreateObjectFromURL(
            sURL,                       // URL of the source.
            MF_RESOLUTION_MEDIASOURCE,  // Create a source object.
            NULL,                       // Optional property store.
            &ObjectType,                // Receives the created object type. 
            &pUnkSource                 // Receives a pointer to the media source.
            );
    }

    // Get the IMFMediaSource from the IUnknown pointer.
    if (SUCCEEDED(hr))
    {
        hr = pUnkSource->QueryInterface(IID_PPV_ARGS(ppMediaSource));
    }

    SafeRelease(&pSourceResolver);
    SafeRelease(&pUnkSource);
    return hr;
}
Exemple #18
0
JNIEXPORT jlong JNICALL Java_com4j_Native_createInstance(
	JNIEnv* env, jclass __unused__, jstring _progId, jint clsctx, jlong iid1, jlong iid2 ) {
	
	MyGUID iid(iid1,iid2);
	CLSID clsid;
	HRESULT hr;
	JString progId(env,_progId);

	hr = CLSIDFromProgID(progId,&clsid);
	if(FAILED(hr)) {
		if(FAILED(CLSIDFromString( const_cast<LPOLESTR>(LPCOLESTR(progId)),&clsid))) {
			error(env,__FILE__,__LINE__,hr,"Unrecognized CLSID");
			return 0;
		}
	}

	void* p;

	if(clsctx&(CLSCTX_LOCAL_SERVER|CLSCTX_REMOTE_SERVER)) {
		IUnknown* pUnk = NULL;
		hr = CoCreateInstance(clsid,NULL,clsctx,__uuidof(IUnknown),(void**)&pUnk);
		if(FAILED(hr)) {
			error(env,__FILE__,__LINE__,hr,"CoCreateInstance failed");
			return 0;
		}
		hr = OleRun(pUnk);
		if(FAILED(hr)) {
			pUnk->Release();
			error(env,__FILE__,__LINE__,hr,"OleRun failed");
			return 0;
		}
		hr = pUnk->QueryInterface(iid,&p);
		pUnk->Release();

		if(FAILED(hr)) {
			error(env,__FILE__,__LINE__,hr,"QueryInterface failed");
			return 0;
		}

	} else {
		// just the plain CoCreateInstance
		hr = CoCreateInstance(clsid,NULL,clsctx,iid,&p);
		if(FAILED(hr)) {
			error(env,__FILE__,__LINE__,hr,"CoCreateInstance failed");
			return 0;
		}
	}
	return reinterpret_cast<jlong>(p);
}
Exemple #19
0
HRESULT
CSite::HrFilterOutStream(LPSTREAM pSourceStream, LPSTREAM &pOutputStream, DWORD dwFlags)
{
	HRESULT hr = S_OK;
//	IStream* pOutputStream = NULL;
	ITriEditDocument* pTriEditDoc = NULL;
	IUnknown* lpUnk = NULL;
	IUnknown* lpStreamUnk = NULL;
	
	lpUnk = GetObjectUnknown();

	if (NULL == lpUnk)
		return E_FAIL;

	// get ITriEditDoc
	if (FAILED(hr = lpUnk->QueryInterface(IID_ITriEditDocument, (LPVOID*) &pTriEditDoc)))
		return hr;

	if (FAILED(hr = pTriEditDoc->FilterOut(pSourceStream, &lpStreamUnk, dwFlags, NULL)))
		goto cleanup;

	if (FAILED(hr = lpStreamUnk->QueryInterface(IID_IStream, (LPVOID*) &pOutputStream)))
		goto cleanup;

//	if (FAILED(hr = HrStreamToFile(pOutputStream, fileName)))
//		goto cleanup;



cleanup:

	ReleaseInterface(pTriEditDoc);
	ReleaseInterface(lpStreamUnk);
//	ReleaseInterface(pOutputStream);
	return hr;
}
Exemple #20
0
inline int getTableIDFromCell(IAccessibleTableCell* tableCell) {
	IUnknown* unk = NULL;
	if (tableCell->get_table(&unk) != S_OK || !unk)
		return 0;
	IAccessible2* acc = NULL;
	HRESULT res;
	res = unk->QueryInterface(IID_IAccessible2, (void**)&acc);
	unk->Release();
	if (res != S_OK || !acc)
		return 0;
	int id=0;
	acc->get_uniqueID((long*)&id);
	acc->Release();
	return id;
}
Exemple #21
0
DWORD CTextildb::Open()
{
	SetCursor(LoadCursor(NULL,IDC_WAIT));
	DWORD					dr;
	DWORD					rc;
	HRESULT					hr;
	IDataInitialize *		pIDataInitialize    = NULL;
	IDBInitialize *			pIDBInitialize      = NULL;
	IDBCreateSession*		pIDBCreateSession	= NULL;
	IUnknown *				pUnkSession			= NULL;
	ICommandText*			pICommandText		= NULL;
	IDBCreateCommand*		pICreateCommand		= NULL;
	char					cConnectionStr[500];
	strcpy(cConnectionStr,"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=bd1.mdb;Persist Security Info=False");
	db_CharToWChar(cConnectionStr);
	for(;;)
	{
		dr = ERR_OLEDBFAIL;
		hr = CoCreateInstance(CLSID_MSDAINITIALIZE,NULL,CLSCTX_INPROC_SERVER,IID_IDataInitialize,(VOID **)&pIDataInitialize);
		if (hr != S_OK) break;
		hr = pIDataInitialize->GetDataSource(NULL,CLSCTX_INPROC_SERVER,(LPCOLESTR)cConnectionStr,IID_IDBInitialize,(IUnknown **)&pIDBInitialize);
		if (hr != S_OK) break;
		hr = pIDBInitialize->Initialize();
		if (hr != S_OK) break;
		hr = pIDBInitialize->QueryInterface(IID_IDBCreateSession, (void**)&pIDBCreateSession);
		if (hr != S_OK) break;
		hr = pIDBCreateSession->CreateSession(NULL,IID_IOpenRowset,&pUnkSession );
		if (hr != S_OK) break;
		hr = pUnkSession->QueryInterface(IID_IDBCreateCommand,(void**)&pICreateCommand);
		if (hr != S_OK) break;
		hr = pICreateCommand->CreateCommand(NULL,IID_ICommand,(IUnknown**)&m_lpICommand);
		if (hr != S_OK) break;
		dr = ERR_NONE;
		break;
	};
	if (pIDataInitialize)	rc = pIDataInitialize->Release();
	if (pIDBInitialize)		rc = pIDBInitialize->Release();
	if (pIDBCreateSession)	rc = pIDBCreateSession->Release();
	if (pUnkSession)		rc = pUnkSession->Release();
	if (pICreateCommand)	rc = pICreateCommand->Release();
	if (hr != S_OK) 
	{
		if (m_lpICommand)		rc = m_lpICommand->Release();
		m_lpICommand = NULL;
	}
	SetCursor(LoadCursor(NULL,IDC_ARROW));
	return ERR_OLEDBFAIL;
}
Exemple #22
0
HRESULT STDMETHODCALLTYPE SourceResolver::Invoke(IMFAsyncResult *pAsyncResult)
{
    QMutexLocker locker(&m_mutex);

    if (!m_sourceResolver)
        return S_OK;

    MF_OBJECT_TYPE ObjectType = MF_OBJECT_INVALID;
    IUnknown* pSource = NULL;
    State *state = static_cast<State*>(pAsyncResult->GetStateNoAddRef());

    HRESULT hr = S_OK;
    if (state->fromStream())
        hr = m_sourceResolver->EndCreateObjectFromByteStream(pAsyncResult, &ObjectType, &pSource);
    else
        hr = m_sourceResolver->EndCreateObjectFromURL(pAsyncResult, &ObjectType, &pSource);

    if (state->sourceResolver() != m_sourceResolver) {
        //This is a cancelled one
        return S_OK;
    }

    if (m_cancelCookie) {
        m_cancelCookie->Release();
        m_cancelCookie = NULL;
    }

    if (FAILED(hr)) {
        emit error(hr);
        return S_OK;
    }

    if (m_mediaSource) {
        m_mediaSource->Release();
        m_mediaSource = NULL;
    }

    hr = pSource->QueryInterface(IID_PPV_ARGS(&m_mediaSource));
    pSource->Release();
    if (FAILED(hr)) {
        emit error(hr);
        return S_OK;
    }

    emit mediaSourceReady();

    return S_OK;
}
Exemple #23
0
static void listWMP()	
{
	char		plug[1024];
	Aregistry	*reg=new Aregistry(WMPREG);
	int			n=0;
	nlist=0;
	while(reg->subEnum(n++, plug, sizeof(plug)-1))
	{
		char		key[1024];
		sprintf(key, "%s\\%s\\Properties", WMPREG, plug);
		{
			Aregistry	*r=new Aregistry(key);
			char		name[1024],desc[1024],classid[1024];
			
			r->read("classid", classid, sizeof(classid));
			r->read("name", name, sizeof(name));
			r->read("description", desc, sizeof(desc));

			{
				CLSID	clsid;
				WCHAR	wclassid[1024];
				b2wchar(wclassid, classid);
				CLSIDFromString(wclassid, &clsid);
				{
					IUnknown		*unk;
					HRESULT			hr;
					hr=CoCreateInstance(clsid, 0, CLSCTX_INPROC_SERVER, IID_IUnknown, (void**)&unk);
					if(hr==S_OK)
					{
						IWMPEffects	*plugin;
						if(unk->QueryInterface(IID_IWMPEffects, (void **)&plugin)==S_OK)
						{
							strcpy(elist[nlist].name, name);
							strcpy(elist[nlist].desc, desc);
							elist[nlist].clsid=clsid;
							nlist++;
							plugin->Release();
						}
						unk->Release();
					}
				}
			}
			
			delete(r);
		}
	}
	delete(reg);
}
Exemple #24
0
// Get a dispatch pointer from the current object associated
// with a ProgID
bool wxAutomationObject::GetInstance(const wxString& progId, int flags) const
{
    if (m_dispatchPtr)
        return false;

    CLSID clsId;
    HRESULT hr = wxCLSIDFromProgID(progId, clsId);
    if (FAILED(hr))
        return false;

    IUnknown *pUnk = NULL;
    hr = GetActiveObject(clsId, NULL, &pUnk);
    if (FAILED(hr))
    {
        if ( flags & wxAutomationInstance_CreateIfNeeded )
        {
            const_cast<wxAutomationObject *>(this)->
                m_dispatchPtr = DoCreateInstance(progId, clsId);
            if ( m_dispatchPtr )
                return true;
        }
        else
        {
            // Log an error except if we're supposed to fail silently when the
            // error is that no current instance exists.
            if ( hr != MK_E_UNAVAILABLE ||
                    !(flags & wxAutomationInstance_SilentIfNone) )
            {
                wxLogSysError(hr,
                              _("Cannot get an active instance of \"%s\""),
                              progId);
            }
        }

        return false;
    }

    hr = pUnk->QueryInterface(IID_IDispatch, (LPVOID*) &m_dispatchPtr);
    if (FAILED(hr))
    {
        wxLogSysError(hr,
                      _("Failed to get OLE automation interface for \"%s\""),
                      progId);
        return false;
    }

    return true;
}
HRESULT ConnectionPointContainer::getCallback( const IID& interface_, IUnknown** callBack_ )
{
	boost::mutex::scoped_lock guard( cpGuard );
	BOOST_FOREACH( ConnectionPointElem& el, points )
	{
		if( el->getInterface() == interface_ )
		{
			IUnknown *unkn = el->getCallBack();
			if( unkn != NULL )
			{
				HRESULT hResult = unkn->QueryInterface( interface_, (void**)callBack_ );
				return hResult;
			}
		}
	}
	return E_FAIL;
}
bool CNetworkProvider::CheckSpecificInterface(GUID requiredGUID, IBDA_Topology* topology, GUID testGUID,ULONG elementList,IUnknown** element){
	IUnknown* unk;
	try{
		if(IsEqualGUID(testGUID,requiredGUID)){
			if(topology->GetControlNode(0,1,elementList,&unk) == S_OK){
				if(unk->QueryInterface(requiredGUID,(void**) element) == S_OK){
					LOG4CPLUS_DEBUG(logger,"CheckSpecificInterface found element");
					return true;
				}
			}
		}
	}catch(...){
		*element = NULL;
	}
	unk = NULL;
	return false;
}
Exemple #27
0
int main(int argc, char **argv)
{
	FAIL_IF(argc != 2, L"Invalid number of parameters passed to PIXPlug. Usage:\nPIXPlug.exe path-to-assembly", -1)

	CComPtr<ICLRMetaHostPolicy> metaHostPolicy;
	HRESULT hr = CLRCreateInstance(CLSID_CLRMetaHostPolicy, IID_PPV_ARGS(&metaHostPolicy));
	FAIL_HR(hr, L"Failed to initialize the CLR hosting API.", -2);

	std::wstring assembly = lexical_cast<std::wstring, std::string>(argv[1]);

	DWORD cchVersion = 0;
	CComPtr<ICLRRuntimeInfo> runtimeInfo;
	hr = metaHostPolicy->GetRequestedRuntime(
		static_cast<METAHOST_POLICY_FLAGS>(METAHOST_POLICY_HIGHCOMPAT | METAHOST_POLICY_APPLY_UPGRADE_POLICY),
		assembly.c_str(),
		0, 0,
		&cchVersion,
		0, 0, 0,
		IID_PPV_ARGS(&runtimeInfo)
	);
	FAIL_HR(hr, L"Failed to load the specified assembly.", -3);

	CComPtr<ICorRuntimeHost> runtime;
	hr = runtimeInfo->GetInterface(CLSID_CorRuntimeHost, IID_PPV_ARGS(&runtime));
	FAIL_HR(hr, L"Failed to get the CLR runtime host interface.", -4);

	hr = runtime->Start();
	FAIL_HR(hr, L"Failed to start the CLR.", -5);

	IUnknown *appDomainThunk;
	hr = runtime->GetDefaultDomain(&appDomainThunk);
	FAIL_HR(hr, L"Failed to retrieve the default AppDomain.", -6);

	CComPtr<_AppDomain> appDomain;
	hr = appDomainThunk->QueryInterface(IID_PPV_ARGS(&appDomain));
	FAIL_HR(hr, L"Failed to retrieve the default AppDomain.", -7);

	long result = 0;
	bstr_t bstrAssembly(assembly.c_str());
	hr = appDomain->ExecuteAssembly_2(bstrAssembly, &result);
	FAIL_HR(hr, L"Failed to execute the provided assembly.", -8);

	runtime->Stop();

	return result;
}
HX_RESULT CRNGenericContext::_ActualQI( THIS_ REFIID riid, void** ppvObj )
{
    // Check for valid pointer and initialize it
    if (!ppvObj)
	return HXR_POINTER;
    *ppvObj = NULL;												\

    if( IsEqualIID( IID_IUnknown, riid ) )
    {
	    AddRef();
	    CUnknownIMP *pInterface = this;
	    *ppvObj = pInterface;
	    return HXR_OK;
    }

    if( IsEqualIID( IID_IHXContext, riid ) )
    {
	    AddRef();
	    IHXContext *pInterface = this;
	    *ppvObj = pInterface;
	    return HXR_OK;
    }

    if( IsEqualIID( IID_IHXContextUser, riid ) )
    {
	    AddRef();
	    IHXContextUser *pInterface = this;
	    *ppvObj = pInterface;
	    return HXR_OK;
    }

    // Iterate through inner unknowns and ask them
    LISTPOSITION listPos = m_InnerUnks.GetHeadPosition();
    while( listPos )
    {
	IUnknown* pInner = (IUnknown*) m_InnerUnks.GetNext( listPos );
	if( SUCCEEDED( pInner->QueryInterface( riid, ppvObj ) ) )
	{
	    return HXR_OK;
	}
    }

    // Nope, couldn't find it
    return HXR_NOINTERFACE;
}
HRESULT MMDeviceLocator::ActivateCompleted(IActivateAudioInterfaceAsyncOperation *operation)
{
    HRESULT hr = S_OK;
    HRESULT hrActivateResult = S_OK;
    IUnknown *audioInterface = nullptr;

    hr = operation->GetActivateResult(&hrActivateResult, &audioInterface);
    if (SUCCEEDED(hr) && SUCCEEDED(hrActivateResult) && audioInterface != nullptr)
    {
        audioInterface->QueryInterface(IID_PPV_ARGS(&m_AudioClient));
        if (nullptr == m_AudioClient)
        {
            hr = E_FAIL;
        }
    }

    return hr;
}
Exemple #30
0
/**
 * @brief	Updates information about port maps on router.
 */
void UpnpNatAction::UpdateInfo()
{
	HRESULT hResult;

	// Cleanup old port map in case this is an update
	CleanPortMaps();

	// Retrieve current port mappings
	hResult = nat->get_StaticPortMappingCollection(&portMapCollection);
	_ErrorException((hResult != S_OK), "retrieving current port mappings (!= S_OK)", hResult, __LINE__, __FILE__);
	_ErrorException((portMapCollection == NULL), "retrieving current port mappings (NULL)", NULL, __LINE__, __FILE__);

	// Scan through list and load port maps into vector
	// Code is based on MSDN sample
	IUnknown * ptrUnk = NULL;
	hResult = portMapCollection->get__NewEnum(&ptrUnk);
	if (SUCCEEDED(hResult))
	{
		IEnumVARIANT * ptrEnumVar = NULL;
		hResult = ptrUnk->QueryInterface(IID_IEnumVARIANT, (void **) &ptrEnumVar);
		if (SUCCEEDED(hResult))
		{
			VARIANT varCurDevice;
			VariantInit(&varCurDevice);
			ptrEnumVar->Reset();
			// Loop through each port map in the collection
			while (S_OK == ptrEnumVar->Next(1, &varCurDevice, NULL))
			{
				IStaticPortMapping * ptrPortMap = NULL;
				IDispatch * pdispDevice = V_DISPATCH(&varCurDevice);
				if (SUCCEEDED(pdispDevice->QueryInterface(IID_IStaticPortMapping, (void **) &ptrPortMap)))
				{
					// Add port map to vector
					UpnpNatPortMapAction * newPortMap = new (nothrow)UpnpNatPortMapAction(ptrPortMap);
					Utility::DynamicAllocCheck(newPortMap,__LINE__,__FILE__);
					portMaps.Add(newPortMap);						
				}
				VariantClear(&varCurDevice);
			}
			ptrEnumVar->Release();
		}
		ptrUnk->Release();
	}
}