当前位置: 首页>>代码示例>>C++>>正文


C++ IUnknownPtr类代码示例

本文整理汇总了C++中IUnknownPtr的典型用法代码示例。如果您正苦于以下问题:C++ IUnknownPtr类的具体用法?C++ IUnknownPtr怎么用?C++ IUnknownPtr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了IUnknownPtr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

HRESULT
nsScriptablePeer::GetIDispatch(IDispatch **pdisp)
{
    if (pdisp == NULL)
    {
        return E_INVALIDARG;
    }
    *pdisp = NULL;

    IUnknownPtr unk;
    HRESULT hr = mPlugin->pControlSite->GetControlUnknown(&unk);
    if (unk.GetInterfacePtr() == NULL)
    {
		return E_FAIL; 
	}

    IDispatchPtr disp = unk;
    if (disp.GetInterfacePtr() == NULL)
    { 
        return E_FAIL; 
    }

    *pdisp = disp.GetInterfacePtr();
    (*pdisp)->AddRef();

    return S_OK;
}
开发者ID:pauldorn,项目名称:v8monkey,代码行数:27,代码来源:XPConnect.cpp

示例2: _T

STDMETHODIMP MailAttachments::get_Item(LONG index, IMailAttachment** pVal)
{
   try
   {
      if(pVal == 0)
          throw Workshare::ArgumentNullException(_T("pVal"), _T("The return argument may not be null"));

      LONG upper = (LONG)m_Attachments.size();
      if((index <= 0) || (index > upper))
         throw Workshare::System::IndexOutOfRangeException(_T("The index is out of range [1-%d]"), upper);

      IUnknownPtr spUnk = m_Attachments.at(index-1);
      HRESULT hr = spUnk.QueryInterface(__uuidof(IMailAttachment), *pVal);
      if(FAILED(hr))
      {
         std::tostringstream os;
         os << _T("Failed to query the IMailAttachment instance at index ") << index << std::ends;
         throw Workshare::Com::ComException(os.str().c_str(), hr, spUnk);      
      }

   }
   catch(const Workshare::Exception& e)
   {
      return AtlReportError(__uuidof(this), e.Message, __uuidof(IMailAttachments), e.ErrorCode);
   }
   catch(...)
   {
      return ProcessUnhandledException();
   }   
   return S_OK;
}
开发者ID:killbug2004,项目名称:WSProf,代码行数:31,代码来源:MailAttachments.cpp

示例3: NS_ENSURE_TRUE

STDMETHODIMP
WMFByteStream::EndRead(IMFAsyncResult* aResult, ULONG *aBytesRead)
{
  NS_ENSURE_TRUE(aResult, E_POINTER);
  NS_ENSURE_TRUE(aBytesRead, E_POINTER);

  ReentrantMonitorAutoEnter mon(mReentrantMonitor);

  // Extract our state object.
  IUnknownPtr unknown;
  HRESULT hr = aResult->GetObject(&unknown);
  if (FAILED(hr) || !unknown) {
    return E_INVALIDARG;
  }
  AsyncReadRequestState* requestState =
    static_cast<AsyncReadRequestState*>(unknown.GetInterfacePtr());

  // Important: Only advance the read cursor if the caller hasn't seeked
  // since it called BeginRead(). If it has seeked, we still must report
  // the number of bytes read (in *aBytesRead), but we don't advance the
  // read cursor; reads performed after the seek will do that. The SourceReader
  // caller seems to keep track of which async read requested which range
  // to be read, and does call SetCurrentPosition() before it calls EndRead().
  if (mOffset == requestState->mOffset) {
    mOffset += requestState->mBytesRead;
  }

  // Report result.
  *aBytesRead = requestState->mBytesRead;

  LOG("WMFByteStream::EndRead() offset=%lld *aBytesRead=%u mOffset=%lld hr=0x%x eof=%d",
      requestState->mOffset, *aBytesRead, mOffset, hr, (mOffset == mResource->GetLength()));

  return S_OK;
}
开发者ID:lofter2011,项目名称:Icefox,代码行数:35,代码来源:WMFByteStream.cpp

示例4: CoInitialize

bool PreRequisiteCheck::IsComObjectAvailable(CStdString sProgID)
{
	CoInitialize(NULL);
	bool bResult = false;

	{
		IUnknownPtr pObj;
		pObj.CreateInstance(sProgID);
		bResult = (pObj!=NULL);
	}

	CoUninitialize();
	return bResult;
}
开发者ID:killbug2004,项目名称:WSProf,代码行数:14,代码来源:PreRequisiteCheck.cpp

示例5: acquireSiteWindow

void IEToolbar::acquireSiteWindow(IUnknownPtr site) {
  // Query IOleWindow interface from specified site.
  IOleWindowPtr siteOLEWindow;
  const HRESULT getOleWindowResult =
      site.QueryInterface(IID_IOleWindow, &siteOLEWindow);
  if (FAILED(getOleWindowResult)) {
    throw _com_error(getOleWindowResult);
  }

  // Retrieve handle of site window.
  HWND siteWindowHandle = 0;
  const HRESULT getWindowResult = siteOLEWindow->GetWindow(&siteWindowHandle);
  if (FAILED(getWindowResult)) {
    throw _com_error(getWindowResult);
  }

  // Attach MFC-wrapper to site window.
  const BOOL attachResult = siteWindow_.Attach(siteWindowHandle);
  if (FALSE == attachResult) {
    throw Error("Failed to attach to site window handle\n");
  }

  // Subclass site window to retrieve its messages.
  subclassWindow(siteWindow_.GetSafeHwnd());
}
开发者ID:Inzaghi2012,项目名称:ie-toolbar,代码行数:25,代码来源:IEToolbar.cpp

示例6: InitializeClr

static void InitializeClr(void)
{
	ICorRuntimeHost *runtimeHost;

	if (FAILED(CorBindToRuntimeEx(NULL, NULL,
	    STARTUP_LOADER_OPTIMIZATION_SINGLE_DOMAIN | STARTUP_CONCURRENT_GC,
	    CLSID_CorRuntimeHost, IID_ICorRuntimeHost, (void **)&runtimeHost))) {
		return;
	}

	runtimeHost->Start();

	IUnknownPtr punkAppDomain = NULL;
	runtimeHost->GetDefaultDomain(&punkAppDomain);

	punkAppDomain->QueryInterface(__uuidof(mscorlib::_AppDomain), (void **)&l_AppDomain);

	runtimeHost->Release();
}
开发者ID:frjaraur,项目名称:icinga2,代码行数:19,代码来源:clrchecktask.cpp

示例7: Reference

Reference *
Reference::getActiveObject (REFCLSID clsid, const Interface *pInterface)
{
    HRESULT hr;

    // Retrieve the instance of the object.
    IUnknownPtr pActive;
    hr = GetActiveObject(clsid, NULL, &pActive);
    if (FAILED(hr)) {
        _com_issue_error(hr);
    }

    // If we know it's a custom interface, then query for an interface pointer
    // to that interface, otherwise query for an IUnknown interface.
    IUnknown *pUnknown;
    hr = pActive->QueryInterface(
        (pInterface == 0) ? IID_IUnknown : pInterface->iid(),
        reinterpret_cast<void **>(&pUnknown));
    if (FAILED(hr)) {
        _com_issue_error(hr);
    }

    if (pInterface == 0) {
        pInterface = findInterface(pUnknown, clsid);
        if (pInterface != 0) {
            // Get a pointer to the derived interface.
            IUnknown *pNew;
            hr = pUnknown->QueryInterface(
                pInterface->iid(),
                reinterpret_cast<void **>(&pNew));
            if (SUCCEEDED(hr)) {
                pUnknown->Release();
                pUnknown = pNew;
            }
        }
    }

    return new Reference(pUnknown, pInterface, clsid);
}
开发者ID:jbroll,项目名称:tcom,代码行数:39,代码来源:Reference.cpp

示例8: acquireSite

void IEToolbar::acquireSite(IUnknownPtr site) {
  // Query IInputObjectSite from specified site.
  IInputObjectSite* sitePtr = 0;
  const HRESULT getSiteResult = site->QueryInterface(IID_IInputObjectSite,
      reinterpret_cast<void**>(&sitePtr));
  if (FAILED(getSiteResult)) {
    throw _com_error(getSiteResult);
  }

  // Set up new site for toolbar.
  releaseSite();
  site_ = sitePtr;
}
开发者ID:Inzaghi2012,项目名称:ie-toolbar,代码行数:13,代码来源:IEToolbar.cpp

示例9: LOG

// IMFAsyncCallback::Invoke implementation. This is called back on the work
// queue thread, and performs the actual read.
STDMETHODIMP
WMFByteStream::Invoke(IMFAsyncResult* aResult)
{
  // Note: We assume that the WMF Work Queue that calls this function does
  // so synchronously, i.e. this function call returns before any other
  // work queue item runs. This is important, as if we run multiple instances
  // of this function at once we'll interleave seeks and reads on the
  // media resoure.

  // Extract the caller's IMFAsyncResult object from the wrapping aResult object.
  IMFAsyncResultPtr callerResult;
  IUnknownPtr unknown;
  HRESULT hr = aResult->GetState(&unknown);
  NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
  callerResult = unknown;
  NS_ENSURE_TRUE(callerResult, E_FAIL);

  // Get the object that holds our state information for the asynchronous call.
  hr = callerResult->GetObject(&unknown);
  NS_ENSURE_TRUE(SUCCEEDED(hr) && unknown, hr);
  AsyncReadRequestState* requestState =
    static_cast<AsyncReadRequestState*>(unknown.GetInterfacePtr());

  // Ensure the read head is at the correct offset in the resource. It may not
  // be if the SourceReader seeked.
  if (mResource->Tell() != requestState->mOffset) {
    nsresult rv = mResource->Seek(nsISeekableStream::NS_SEEK_SET,
                                  requestState->mOffset);
    if (NS_FAILED(rv)) {
      // Let SourceReader know the read failed.
      callerResult->SetStatus(E_FAIL);
      wmf::MFInvokeCallback(callerResult);
      LOG("WMFByteStream::Invoke() seek to read offset failed, aborting read");
      return S_OK;
    }
  }
  NS_ASSERTION(mResource->Tell() == requestState->mOffset, "State mismatch!");

  // Read in a loop to ensure we fill the buffer, when possible.
  ULONG totalBytesRead = 0;
  nsresult rv = NS_OK;
  while (totalBytesRead < requestState->mBufferLength) {
    BYTE* buffer = requestState->mBuffer + totalBytesRead;
    ULONG bytesRead = 0;
    ULONG length = requestState->mBufferLength - totalBytesRead;
    rv = mResource->Read(reinterpret_cast<char*>(buffer),
                         length,
                         reinterpret_cast<uint32_t*>(&bytesRead));
    totalBytesRead += bytesRead;
    if (NS_FAILED(rv) || bytesRead == 0) {
      break;
    }
  }

  // Record the number of bytes read, so the caller can retrieve
  // it later.
  requestState->mBytesRead = NS_SUCCEEDED(rv) ? totalBytesRead : 0;
  callerResult->SetStatus(S_OK);

  LOG("WMFByteStream::Invoke() read %d at %lld finished rv=%x",
       requestState->mBytesRead, requestState->mOffset, rv);

  // Let caller know read is complete.
  wmf::MFInvokeCallback(callerResult);

  return S_OK;
}
开发者ID:lofter2011,项目名称:Icefox,代码行数:69,代码来源:WMFByteStream.cpp

示例10: DoAction

bool CFirewallOpener::DoAction(const EFOCAction eAction, const CICSRuleInfo& riPortRule){
	if ( !Init() )
		return false;
	//TODO lets see if we can find a reliable method to find out the internet standard connection set by the user

	bool bSuccess = true;
	bool bPartialSucceeded = false;
	bool bFoundAtLeastOneConn = false;

	INetSharingEveryConnectionCollectionPtr NSECCP;
	IEnumVARIANTPtr varEnum;
    IUnknownPtr pUnk;
    RETURN_ON_FAIL(m_pINetSM->get_EnumEveryConnection(&NSECCP));
    RETURN_ON_FAIL(NSECCP->get__NewEnum(&pUnk));
	RETURN_ON_FAIL(pUnk->QueryInterface(__uuidof(IEnumVARIANT), (void**)&varEnum));
	
	_variant_t var;
	while (S_OK == varEnum->Next(1, &var, NULL)) {
		INetConnectionPtr NCP;		
		if (V_VT(&var) == VT_UNKNOWN
			&& SUCCEEDED(V_UNKNOWN(&var)->QueryInterface(__uuidof(INetConnection),(void**)&NCP))) 
		{
			INetConnectionPropsPtr pNCP;
			if ( !SUCCEEDED(m_pINetSM->get_NetConnectionProps (NCP, &pNCP)) )
				continue;	
			DWORD dwCharacteristics = 0;
			pNCP->get_Characteristics(&dwCharacteristics);
			if (dwCharacteristics & (NCCF_FIREWALLED)) {
				NETCON_MEDIATYPE MediaType = NCM_NONE;
				pNCP->get_MediaType (&MediaType);
				if ((MediaType != NCM_SHAREDACCESSHOST_LAN) && (MediaType != NCM_SHAREDACCESSHOST_RAS) ){
					INetSharingConfigurationPtr pNSC;
					if ( !SUCCEEDED(m_pINetSM->get_INetSharingConfigurationForINetConnection (NCP, &pNSC)) )
						continue;
					VARIANT_BOOL varbool = VARIANT_FALSE;
					pNSC->get_InternetFirewallEnabled(&varbool);
					if (varbool == VARIANT_FALSE)
						continue;
					bFoundAtLeastOneConn = true;
					switch(eAction){
							case FOC_ADDRULE:{
								bool bResult;
								// we do not want to overwrite an existing rule
								if (FindRule(FOC_FINDRULEBYPORT, riPortRule, pNSC, NULL)){
									bResult = true;
								}
								else
									bResult = AddRule(riPortRule, pNSC, pNCP);
								bSuccess = bSuccess && bResult;
								if (bResult && !bPartialSucceeded)
									m_liAddedRules.Add(riPortRule); // keep track of added rules
								bPartialSucceeded = bPartialSucceeded || bResult;
								break;
							}
							case FOC_FWCONNECTIONEXISTS:
								return true;
							case FOC_DELETERULEBYNAME:
							case FOC_DELETERULEEXCACT:
								bSuccess = bSuccess && FindRule(eAction, riPortRule, pNSC, NULL);
								break;
							case FOC_FINDRULEBYNAME:
								if (FindRule(FOC_FINDRULEBYNAME, riPortRule, pNSC, NULL))
									return true;
								else
									bSuccess = false;
								break;
							case FOC_FINDRULEBYPORT:
								if (FindRule(FOC_FINDRULEBYPORT, riPortRule, pNSC, NULL))
									return true;
								else
									bSuccess = false;
								break;
							default:
								ASSERT ( false );
					}
				}
			}
		}
		var.Clear();
	}
	return bSuccess && bFoundAtLeastOneConn;
}
开发者ID:BackupTheBerlios,项目名称:resurrection,代码行数:82,代码来源:FirewallOpener.cpp

示例11: RETURN_ON_FAIL

bool CFirewallOpener::FindRule(const EFOCAction eAction, const CICSRuleInfo& riPortRule, const INetSharingConfigurationPtr pNSC, INetSharingPortMappingPropsPtr* outNSPMP){
	INetSharingPortMappingCollectionPtr pNSPMC;
    RETURN_ON_FAIL(pNSC->get_EnumPortMappings (ICSSC_DEFAULT, &pNSPMC));
       
	INetSharingPortMappingPtr pNSPM;
    IEnumVARIANTPtr varEnum;
    IUnknownPtr pUnk;
    RETURN_ON_FAIL(pNSPMC->get__NewEnum(&pUnk));
    RETURN_ON_FAIL(pUnk->QueryInterface(__uuidof(IEnumVARIANT), (void**)&varEnum));
	_variant_t var;
	while (S_OK == varEnum->Next(1, &var, NULL)) {
		INetSharingPortMappingPropsPtr pNSPMP;
		if (V_VT(&var) == VT_DISPATCH
			&& SUCCEEDED(V_DISPATCH(&var)->QueryInterface(__uuidof(INetSharingPortMapping),(void**)&pNSPM)) 
			&& SUCCEEDED(pNSPM->get_Properties (&pNSPMP)))
		{
			UCHAR ucProt = 0;
			long uExternal = 0;
			CComBSTR bstrName;
			pNSPMP->get_IPProtocol (&ucProt);
			pNSPMP->get_ExternalPort (&uExternal);
			pNSPMP->get_Name(&bstrName);
			switch(eAction){
				case FOC_FINDRULEBYPORT:
					if (riPortRule.m_nPortNumber == uExternal && riPortRule.m_byProtocol == ucProt){
						if (outNSPMP != NULL)
							*outNSPMP = pNSPM;
						return true;
					}
					break;
				case FOC_FINDRULEBYNAME:
					if (riPortRule.m_strRuleName == CString(bstrName)){
						if (outNSPMP != NULL)
							*outNSPMP = pNSPM;
						return true;
					}
					break;
				case FOC_DELETERULEEXCACT:
					if (riPortRule.m_strRuleName == CString(bstrName)
						&& riPortRule.m_nPortNumber == uExternal && riPortRule.m_byProtocol == ucProt)
					{
						RETURN_ON_FAIL(pNSC->RemovePortMapping(pNSPM));
						theApp.QueueDebugLogLine(false,_T("Rule removed"));
					}
					break;
				case FOC_DELETERULEBYNAME:
					if (riPortRule.m_strRuleName == CString(bstrName)){
						RETURN_ON_FAIL(pNSC->RemovePortMapping(pNSPM));
						theApp.QueueDebugLogLine(false,_T("Rule removed"));
					}
					break;
				default:
					ASSERT( false );
			}
		}
		var.Clear();
	}

	switch(eAction){
		case FOC_DELETERULEBYNAME:
		case FOC_DELETERULEEXCACT:
			return true;
		case FOC_FINDRULEBYPORT:
		case FOC_FINDRULEBYNAME:
		default:
			return false;
	}
}
开发者ID:BackupTheBerlios,项目名称:resurrection,代码行数:68,代码来源:FirewallOpener.cpp

示例12: _tmain

int _tmain(int argc, _TCHAR* argv[])
{
	HRESULT hr;

	ICLRMetaHost *pMetaHost = NULL;
	ICLRRuntimeInfo *pRuntimeInfo = NULL;
	ICorRuntimeHost *pCorRuntimeHost = NULL;

	IUnknownPtr spAppDomainThunk = NULL;
	_AppDomainPtr spDefaultAppDomain = NULL;

	// The .NET assembly to load.
	bstr_t bstrAssemblyName("PowerShellRunner");
	_AssemblyPtr spAssembly = NULL;

	// The .NET class to instantiate.
	bstr_t bstrClassName("PowerShellRunner.PowerShellRunner");
	_TypePtr spType = NULL;


	// Start the runtime
	hr = CLRCreateInstance(CLSID_CLRMetaHost, IID_PPV_ARGS(&pMetaHost));
	if (FAILED(hr))
	{
		wprintf(L"CLRCreateInstance failed w/hr 0x%08lx\n", hr);
		goto Cleanup;
	}

	hr = pMetaHost->GetRuntime(L"v2.0.50727", IID_PPV_ARGS(&pRuntimeInfo));
	if (FAILED(hr))
	{
		wprintf(L"ICLRMetaHost::GetRuntime failed w/hr 0x%08lx\n", hr);
		goto Cleanup;
	}

	// Check if the specified runtime can be loaded into the process.
	BOOL fLoadable;
	hr = pRuntimeInfo->IsLoadable(&fLoadable);
	if (FAILED(hr))
	{
		wprintf(L"ICLRRuntimeInfo::IsLoadable failed w/hr 0x%08lx\n", hr);
		goto Cleanup;
	}

	if (!fLoadable)
	{
		wprintf(L".NET runtime v2.0.50727 cannot be loaded\n");
		goto Cleanup;
	}

	// Load the CLR into the current process and return a runtime interface
	hr = pRuntimeInfo->GetInterface(CLSID_CorRuntimeHost,
		IID_PPV_ARGS(&pCorRuntimeHost));
	if (FAILED(hr))
	{
		wprintf(L"ICLRRuntimeInfo::GetInterface failed w/hr 0x%08lx\n", hr);
		goto Cleanup;
	}

	// Start the CLR.
	hr = pCorRuntimeHost->Start();
	if (FAILED(hr))
	{
		wprintf(L"CLR failed to start w/hr 0x%08lx\n", hr);
		goto Cleanup;
	}


	// Get a pointer to the default AppDomain in the CLR.
	hr = pCorRuntimeHost->GetDefaultDomain(&spAppDomainThunk);
	if (FAILED(hr))
	{
		wprintf(L"ICorRuntimeHost::GetDefaultDomain failed w/hr 0x%08lx\n", hr);
		goto Cleanup;
	}

	hr = spAppDomainThunk->QueryInterface(IID_PPV_ARGS(&spDefaultAppDomain));
	if (FAILED(hr))
	{
		wprintf(L"Failed to get default AppDomain w/hr 0x%08lx\n", hr);
		goto Cleanup;
	}

	// Load the .NET assembly.
	// (Option 1) Load it from disk - usefully when debugging the PowerShellRunner app (you'll have to copy the DLL into the same directory as the exe)
	//hr = spDefaultAppDomain->Load_2(bstrAssemblyName, &spAssembly);
	
	// (Option 2) Load the assembly from memory
	SAFEARRAYBOUND bounds[1];
	bounds[0].cElements = PowerShellRunner_dll_len;
	bounds[0].lLbound = 0;

	SAFEARRAY* arr = SafeArrayCreate(VT_UI1, 1, bounds);
	SafeArrayLock(arr);
	memcpy(arr->pvData, PowerShellRunner_dll, PowerShellRunner_dll_len);
	SafeArrayUnlock(arr);

	hr = spDefaultAppDomain->Load_3(arr, &spAssembly);

	if (FAILED(hr))
//.........这里部分代码省略.........
开发者ID:Meatballs1,项目名称:UnmanagedPowerShell,代码行数:101,代码来源:UnmanagedPowerShell.cpp

示例13: initialize_dotnet_host

DWORD initialize_dotnet_host()
{
	HRESULT hr = S_OK;
	ICLRMetaHost* clrMetaHost = NULL;
	ICLRRuntimeInfo* clrRuntimeInfo = NULL;
	ICorRuntimeHost* clrCorRuntimeHost = NULL;
	IUnknownPtr clrAppDomain = NULL;
	_AppDomainPtr clrAppDomainInterface = NULL;
	_AssemblyPtr clrPowershellAssembly = NULL;
	_TypePtr clrPowershellType = NULL;
	SAFEARRAY* clrByteArray = NULL;
	HMODULE hMsCoree = NULL;

	do
	{
		dprintf("[PSH] Locating CLR instance ...");
		hMsCoree = LoadLibraryA("mscoree.dll");
		if (hMsCoree == NULL)
		{
			hr = (HRESULT)GetLastError();
			dprintf("[PSH] Failed to load mscoree, .NET probably isn't installed. 0x%x", hr);
			break;
		}

		pClrCreateInstance clrCreateInstance = (pClrCreateInstance)GetProcAddress(hMsCoree, "CLRCreateInstance");
		if (clrCreateInstance != NULL)
		{
			dprintf("[PSH] .NET 4 method in use");

			if (FAILED(hr = clrCreateInstance(CLSID_CLRMetaHost, IID_PPV_ARGS(&clrMetaHost))))
			{
				dprintf("[PSH] Failed to create instace of the CLR metahost 0x%x", hr);
				break;
			}

			dprintf("[PSH] Getting a reference to the .NET runtime");
			if (FAILED(hr = clrMetaHost->GetRuntime(L"v2.0.50727", IID_PPV_ARGS(&clrRuntimeInfo))))
			{
				dprintf("[PSH] Failed to get runtime v2.0.50727 instance 0x%x", hr);
				if (FAILED(hr = clrMetaHost->GetRuntime(L"v4.0.30319", IID_PPV_ARGS(&clrRuntimeInfo))))
				{
					dprintf("[PSH] Failed to get runtime v4.0.30319 instance 0x%x", hr);
					break;
				}
			}

			dprintf("[PSH] Determining loadablility");
			BOOL loadable = FALSE;
			if (FAILED(hr = clrRuntimeInfo->IsLoadable(&loadable)))
			{
				dprintf("[PSH] Unable to determine of runtime is loadable 0x%x", hr);
				break;
			}

			if (!loadable)
			{
				dprintf("[PSH] Chosen runtime isn't loadable, exiting.");
				break;
			}

			dprintf("[PSH] Instantiating the COR runtime host");
			hr = clrRuntimeInfo->GetInterface(CLSID_CorRuntimeHost, IID_PPV_ARGS(&clrCorRuntimeHost));
			if (FAILED(hr))
			{
				dprintf("[PSH] Unable to get a reference to the COR runtime host 0x%x", hr);
				break;
			}
		}
		else
		{
			dprintf("[PSH] .NET 4 method is missing, attempting to locate .NEt 2 method");
			pCorBindToRuntime corBindToRuntime = (pCorBindToRuntime)GetProcAddress(hMsCoree, "CorBindToRuntime");
			if (corBindToRuntime == NULL)
			{
				dprintf("[PSH] Unable to find .NET clr instance loader");
				hr = E_NOTIMPL;
				break;
			}

			if (FAILED(hr = corBindToRuntime(L"v2.0.50727", L"wks", CLSID_CorRuntimeHost, IID_PPV_ARGS(&clrCorRuntimeHost))))
			{
				dprintf("[PSH] Unable to bind to .NET 2 runtime host: 0x%x", hr);
				break;
			}
		}

		dprintf("[PSH] Starting the COR runtime host");
		if (FAILED(hr = clrCorRuntimeHost->Start()))
		{
			dprintf("[PSH] Unable to start the COR runtime host 0x%x", hr);
			break;
		}

		dprintf("[PSH] Getting a ref to the app domain");
		if (FAILED(hr = clrCorRuntimeHost->GetDefaultDomain(&clrAppDomain)))
		{
			dprintf("[PSH] Unable to get the app domain 0x%x", hr);
			break;
		}

//.........这里部分代码省略.........
开发者ID:bushalo,项目名称:metasploit-payloads,代码行数:101,代码来源:powershell_bridge.cpp

示例14: InsertGif

void CExRichEditWindowless::InsertGif(LONG gif)
{
	CComQIPtr<IDynamicOleCom> spDyn;
	HRESULT hr = spDyn.CoCreateInstance(STR_PROGID);
	if(SUCCEEDED(hr))
	{
		LPOLEOBJECT lpOleObject = NULL;
		HRESULT hr = spDyn->QueryInterface(IID_IOleObject, (void**)&lpOleObject);

		IUnknownPtr lpUnk = lpOleObject;
		hr = lpUnk->QueryInterface(IID_IOleObject, (LPVOID*)&lpOleObject);
		if (lpOleObject == NULL)
			throw(E_OUTOFMEMORY);
		//hr = lpOleObject->SetClientSite( static_cast<IOleClientSite *>( this ) );
		IViewObject2Ptr lpViewObject;// IViewObject for IOleObject above
		hr = lpOleObject->QueryInterface(IID_IViewObject2, (LPVOID*)&lpViewObject);
		if (hr != S_OK)
		{
			AtlThrow(hr);
		}
		IRichEditOle* pRichEditOle = GetIRichEditOle();
		////获取RichEdit的OLEClientSite
		IOleClientSitePtr lpClientSite;
		hr = pRichEditOle->GetClientSite(&lpClientSite);

		if (hr != S_OK)
		{
			AtlThrow(hr);
		}
		REOBJECT reobject;
		ZeroMemory(&reobject,sizeof(REOBJECT));
		reobject.cbStruct = sizeof(REOBJECT);

		CLSID clsid;
		hr = lpOleObject->GetUserClassID(&clsid);
		if (hr != S_OK)
		{
			AtlThrow(hr);
		}

		reobject.clsid = clsid;
		reobject.cp = -1;
		//reobject.cp = REO_CP_SELECTION;
		reobject.dvaspect = DVASPECT_CONTENT;//DVASPECT_OPAQUE;
		reobject.poleobj = lpOleObject;
		reobject.polesite = lpClientSite;
		//reobject.pstg = lpStorage;
		SIZEL sizel;
		sizel.cx = sizel.cy = 0; // let richedit determine initial size

		Image* img = (Image*)gif;
		SIZEL sizeInPix = {img->GetWidth(), img->GetHeight()};
		SIZEL sizeInHiMetric;
		AtlPixelToHiMetric(&sizeInPix, &sizeInHiMetric);

		reobject.sizel = sizeInHiMetric;
		reobject.dwFlags = REO_BELOWBASELINE|REO_STATIC;//REO_RESIZABLE

		CExRichEditData* pdata = new CExRichEditData;
		pdata->m_dataType = GIF;
		pdata->m_data = (void*)gif;
		reobject.dwUser = (DWORD)pdata;//TODO 用户数据

		lpOleObject->SetClientSite(lpClientSite); 
		hr = pRichEditOle->InsertObject(&reobject);
		lpOleObject->SetExtent(DVASPECT_CONTENT, &sizeInHiMetric);
		OleSetContainedObject(lpOleObject, TRUE);
		lpOleObject->Release();
		spDyn->SetHostWindow((LONG)hwndParent);
		spDyn->InsertGif(gif);
	}
}
开发者ID:hhchen1209,项目名称:RichEditDemo,代码行数:72,代码来源:RichEditWindowless.cpp

示例15: GetMenuMgr

/*----------------------------------------------------------------------------------------------
	The hwnd has been attached.
----------------------------------------------------------------------------------------------*/
void HwMainWnd::PostAttach(void)
{
	StrAppBuf strbT; // Holds temp string

	// Set the default caption text.
	strbT.Load(kstidHelloWorld);
	::SendMessage(m_hwnd, WM_SETTEXT, 0, (LPARAM)strbT.Chars());

	// This creates the main frame window and sets it as the current window. It also
	// creates the rebar and status bar.
	SuperClass::PostAttach();

	const int rgrid[] =
	{
		kridTBarStd,
		kridHwTBarIns,
		kridHwTBarTools,
		kridHwTBarWnd,
	};

	GetMenuMgr()->LoadToolBars(rgrid, SizeOfArray(rgrid));

	// Create the menu bar.
	AfMenuBarPtr qmnbr;
	qmnbr.Create();
	qmnbr->Initialize(m_hwnd, kridAppMenu, kridAppMenu, "Menu Bar");
	m_vqtlbr.Push(qmnbr.Ptr());

	// Create the toolbars.
	AfToolBarPtr qtlbr;

	qtlbr.Create();
	qtlbr->Initialize(kridTBarStd, kridTBarStd, "Standard");
	m_vqtlbr.Push(qtlbr);

	qtlbr.Create();
	qtlbr->Initialize(kridHwTBarIns, kridHwTBarIns, "Insert");
	m_vqtlbr.Push(qtlbr);

	qtlbr.Create();
	qtlbr->Initialize(kridHwTBarTools, kridHwTBarTools, "Tools");
	m_vqtlbr.Push(qtlbr);

	qtlbr.Create();
	qtlbr->Initialize(kridHwTBarWnd, kridHwTBarWnd, "Window");
	m_vqtlbr.Push(qtlbr);

	// Load window settings.
	LoadSettings(NULL, false);

	g_app.AddCmdHandler(this, 1);
	m_qstbr->RestoreStatusText();

	// Create the client window.
	const int kwidChild = 1000;
	WndCreateStruct wcs;
	wcs.InitChild("STATIC", m_hwnd, kwidChild);
	m_qwndHost.Create();
	m_qwndHost->CreateAndSubclassHwnd(wcs);

	Assert(memcmp(&CLSID_SaCtrlEvent, &DIID__DSAEvents, isizeof(GUID)) == 0);

	CComCoClass<SaCtrlEvent>::CreateInstance(&m_qsce);
	IUnknownPtr qunk;
	CheckHr(AtlAxCreateControlEx(L"SA.SACtrl.1", m_qwndHost->Hwnd(), NULL, NULL, &qunk,
		DIID__DSAEvents, (IUnknown *)m_qsce.Ptr()));
	CheckHr(qunk->QueryInterface(DIID__DSA, (void **)&m_qctrl));
	m_qsce->Init(this, m_qctrl);
	StrUni stu(L"baluchi.wav");
	CheckHr(m_qctrl->put_WaveFile(stu.Bstr()));
	CheckHr(m_qctrl->raw_SetGraphs(GRAPH_MAGNITUDE, GRAPH_MAGNITUDE));
	CheckHr(m_qctrl->put_ShowContextMenu(false));
	CheckHr(m_qctrl->put_ShowCursorContextMenu(false));

	::ShowWindow(m_qwndHost->Hwnd(), SW_SHOW);

	g_app.AddCmdHandler(this, 1);
}
开发者ID:FieldDB,项目名称:FieldWorks,代码行数:81,代码来源:HelloWorld.cpp


注:本文中的IUnknownPtr类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。