コード例 #1
0
ファイル: oledll.cpp プロジェクト: shuowen/OpenNT
SCODE AFXAPI AfxDllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
{
    SCODE sc;
    *ppv = NULL;

    AFX_OLE_STATE* pOleState = AfxGetOleState();
    // search factories defined in the application
    for (COleObjectFactory* pFactory = pOleState->m_pFirstFactory;
            pFactory != NULL; pFactory = pFactory->m_pNextFactory)
    {
        if (pFactory->m_dwRegister != 0 && pFactory->m_clsid == rclsid)
        {
            // found suitable class factory -- query for correct interface
            sc = pFactory->ExternalQueryInterface(&riid, ppv);
            if (sc != NOERROR)
                return sc;
#ifndef _UNICODE
            LPUNKNOWN lpUnk = (LPUNKNOWN)*ppv;
            ASSERT(lpUnk != NULL);
            sc = ::Ole2AnsiWFromA(riid, lpUnk, (LPUNKNOWN*)ppv);
            lpUnk->Release();
#endif
            return sc;
        }
    }
#ifdef _AFXDLL
    // search factories defined in extension DLLs
    AFX_CORE_STATE* pCoreState = AfxGetCoreState();
    for (CDynLinkLibrary* pDLL = pCoreState->m_pFirstDLL; pDLL != NULL;
            pDLL = pDLL->m_pNextDLL)
    {
        for (pFactory = pDLL->m_pFirstSharedFactory;
                pFactory != NULL; pFactory = pFactory->m_pNextFactory)
        {
            if (pFactory->m_dwRegister != 0 && pFactory->m_clsid == rclsid)
            {
                // found suitable class factory -- query for correct interface
                sc = pFactory->ExternalQueryInterface(&riid, ppv);
                if (sc != NOERROR)
                    return sc;
#ifndef _UNICODE
                LPUNKNOWN lpUnk = (LPUNKNOWN)*ppv;
                ASSERT(lpUnk != NULL);
                sc = ::Ole2AnsiWFromA(riid, lpUnk, (LPUNKNOWN*)ppv);
                lpUnk->Release();
#endif
                return sc;
            }
        }
    }
#endif

    // factory not registered -- return error
    return CLASS_E_CLASSNOTAVAILABLE;
}
コード例 #2
0
CDlgIADsPropertyList::CDlgIADsPropertyList(LPUNKNOWN pUnk, CWnd* pParent /*=NULL*/)
    : CDialog(CDlgIADsPropertyList::IDD, pParent)
{
    //{{AFX_DATA_INIT(CDlgIADsPropertyList)
    m_sAttribute = _T("");
    //}}AFX_DATA_INIT

    HRESULT hr;
    m_pPropList = NULL;
    hr = pUnk->QueryInterface( IID_IADsPropertyList, (void **) &m_pPropList );
    if ( !SUCCEEDED(hr) )
    {
        AfxMessageBox(_T("Fatal Error! QI for IADsPropertyList failed"));
        return;
    }
    pUnk->Release();


    //////////////////////////////////////////
    // Retrieve the data to the cache
    ////////////////////////////////////////////
    IADs *pADs=NULL;
    hr = m_pPropList->QueryInterface( IID_IADs, (void**) &pADs );
    if ( SUCCEEDED(hr) )
    {
        hr = pADs->GetInfo();
        pADs->Release();
    }



}
コード例 #3
0
void CADQIDlg::EnumerateInterface()
{
    int xx=0;
    HRESULT hr;
    LPUNKNOWN pQI;

    m_cListIf.ResetContent();

    ///////////////////////////////////////////////////////////////
    // Query Interface all known ADSI Interfaces
    ////////////////////////////////////////////////////////////////
    while( !IsEqualIID( *adsiIfs[xx].pIID, IID_NULL ) )
    {
        hr = m_pUnk->QueryInterface( *adsiIfs[xx].pIID, (void**) &pQI );
        if ( SUCCEEDED(hr) )
        {
            m_cListIf.AddString( adsiIfs[xx].szIf );
            pQI->Release();
        }
        xx++;
    }



}
コード例 #4
0
CDlgIDirectoryObject::CDlgIDirectoryObject(LPUNKNOWN pUnk, CWnd* pParent /*=NULL*/)
	: CDialog(CDlgIDirectoryObject::IDD, pParent)
{
	//{{AFX_DATA_INIT(CDlgIDirectoryObject)
	m_sDN = _T("");
	m_sRDN = _T("");
	m_sSchema = _T("");
	m_sClass = _T("");
	m_sParent = _T("");
	m_sAttributes = _T("");
	//}}AFX_DATA_INIT

	HRESULT hr;
	m_pDirObject = NULL;
	hr = pUnk->QueryInterface( IID_IDirectoryObject, (void **) &m_pDirObject );
	if ( !SUCCEEDED(hr) )
	{
		AfxMessageBox(_T("Fatal Error! QI for IDirectoryObject failed"));
		return;
	}
	pUnk->Release();

	ShowAttributes();

}
コード例 #5
0
CDlgIDirectorySearch::CDlgIDirectorySearch(LPUNKNOWN pUnk, CWnd* pParent /*=NULL*/)
	: CDialog(CDlgIDirectorySearch::IDD, pParent)
{
	//{{AFX_DATA_INIT(CDlgIDirectorySearch)
	m_sFilter = _T("");
	m_bEnableFilter = FALSE;
	m_nTimeOut = 0;
	m_bCacheResult = FALSE;
	m_nPageSize = 0;
	m_sSortOn = _T("");
	m_nTimeLimit = 0;
	m_nSizeLimit = 0;
	m_bAsynch = FALSE;
	m_bAttrib = FALSE;
	m_nDeref = -1;
	//}}AFX_DATA_INIT
	HRESULT hr;
	m_pSearch = NULL;
	hr = pUnk->QueryInterface( IID_IDirectorySearch, (void **) &m_pSearch );
	if ( !SUCCEEDED(hr) )
	{
		AfxMessageBox(_T("Fatal Error! QI for IDirectorySearch failed"));
		return;
	}
	pUnk->Release();



}
コード例 #6
0
CDlgIADs::CDlgIADs(LPUNKNOWN pUnk, CWnd* pParent /*=NULL*/)
	: CDialog(CDlgIADs::IDD, pParent)
{
	//{{AFX_DATA_INIT(CDlgIADs)
	m_sADsPath = _T("");
	m_sClass = _T("");
	m_sName = _T("");
	m_sParent = _T("");
	m_sSchema = _T("");
	m_sGUID = _T("");
	//}}AFX_DATA_INIT

	///////////////////////////////////////
	// Get the IADs pointer and save it 
	/////////////////////////////////////
	HRESULT hr;
	m_pADs = NULL;
	hr = pUnk->QueryInterface( IID_IADs, (void **) &m_pADs );
	if ( !SUCCEEDED(hr) )
	{
		AfxMessageBox(_T("Fatal Error! QI for IADs failed"));
		return;
	}
	pUnk->Release();
	

}
コード例 #7
0
ファイル: xarraydb.cpp プロジェクト: DeegC/10d
BOOL IXArrayDB::CreateDispatch(REFCLSID clsid, COleException* pError )
{
   ASSERT(m_lpDispatch == NULL);

   m_bAutoRelease = TRUE;  // good default is to auto-release

   // create an instance of the object
   LPUNKNOWN lpUnknown = NULL;
   HRESULT sc = CreateInstanceLic( this->GetCLSID(), NULL,
                                   CLSCTX_ALL | CLSCTX_REMOTE_SERVER,
                                   IID_IUnknown, (zPVOID*)&lpUnknown);
   if (sc == E_INVALIDARG)
   {
      // may not support CLSCTX_REMOTE_SERVER, so try without
      sc = CreateInstanceLic(this->GetCLSID(), NULL, CLSCTX_ALL & ~CLSCTX_REMOTE_SERVER,
         IID_IUnknown, (zPVOID*)&lpUnknown);
   }
   if (FAILED(sc))
      goto Failed;

   // make sure it is running
   sc = OleRun(lpUnknown);
   if (FAILED(sc))
      goto Failed;

   // query for IDispatch interface
   sc = lpUnknown->QueryInterface( IID_IDispatch, (zPVOID*) &m_lpDispatch);
   if (m_lpDispatch == NULL)
      goto Failed;

   lpUnknown->Release();
   ASSERT(m_lpDispatch != NULL);
   return TRUE;

Failed:
   lpUnknown->Release();
   if (pError != NULL)
      pError->m_sc = sc;
   TRACE1("Warning: CreateDispatch returning scode = %s.\n",
      AfxGetFullScodeString(sc));
   return FALSE;
}
コード例 #8
0
ファイル: MA_Misc.cpp プロジェクト: gitter-badger/MA-Engine
DLLEXPORT double MADX9_FreePointer(double p)
{
	LPUNKNOWN ptr = (LPUNKNOWN) DoubleToPtr(p);

	if (ptr == 0)
		return ErrorHandle(mamain->err, ErrorInv);

	ptr->Release();

	return ErrorOk;
}
コード例 #9
0
ファイル: oleconn.cpp プロジェクト: anyue100/winscp
CConnectionPoint::~CConnectionPoint()
{
	POSITION pos = GetStartPosition();
	while (pos != NULL)
	{
		LPUNKNOWN pUnk = GetNextConnection(pos);
		ASSERT(pUnk != NULL);
		pUnk->Release();
	}

	if (m_pConnections != NULL)
		delete m_pConnections;
}
コード例 #10
0
ファイル: DataGridEx.cpp プロジェクト: uesoft/AutoPHS
void CDataGridEx::OnSortDesc()
{
	CString strTemp;
	_RecordsetPtr IRecordset;
	LPUNKNOWN pUnknown;
	HRESULT hr;

	try
	{
		pUnknown=this->GetDataSource();

		hr=pUnknown->QueryInterface(__uuidof(_RecordsetPtr),(void**)&IRecordset);

		if(FAILED(hr))
		{
			pUnknown->Release();
			AfxMessageBox(_com_error(hr).ErrorMessage());
			return;
		}

		pUnknown->Release();

		strTemp=GetColumns().GetItem(_variant_t(m_SelectCol)).GetCaption();

		strTemp+=_T(" DESC");
		IRecordset->Sort=_bstr_t(strTemp);
	}
	catch (_com_error &e)
	{
		CString strMsg;
		strMsg.Format("%s:%d %s", __FILE__, __LINE__, (LPSTR)e.Description());
		AfxMessageBox(strMsg);
	}

	
	return;
}
コード例 #11
0
ファイル: calcdriv.cpp プロジェクト: jetlive/skiaming
BOOL CDriverDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	// create the calculator object that we'll drive through OLE automation
	COleException e;
	CLSID clsid;
	if (CLSIDFromProgID(OLESTR("mfccalc.calculator"), &clsid) != NOERROR)
	{
		AfxMessageBox(IDP_UNABLE_TO_CREATE);
		EndDialog(IDABORT);
		return FALSE;
	}

	// try to get the active calculator before creating a new one
	LPUNKNOWN lpUnk;
	LPDISPATCH lpDispatch;
	if (GetActiveObject(clsid, NULL, &lpUnk) == NOERROR)
	{
		HRESULT hr = lpUnk->QueryInterface(IID_IDispatch,
			(LPVOID*)&lpDispatch);
		lpUnk->Release();
		if (hr == NOERROR)
			m_calc.AttachDispatch(lpDispatch, TRUE);
	}

	// if not dispatch ptr attached yet, need to create one
	if (m_calc.m_lpDispatch == NULL &&
		!m_calc.CreateDispatch(clsid, &e))
	{
		AfxMessageBox(IDP_UNABLE_TO_CREATE);
		EndDialog(IDABORT);
		return FALSE;
	}

	// attempt to make it visible
	m_calc.SetVisible(TRUE);
	if (!m_calc.GetVisible())
	{
		AfxMessageBox(IDP_UNABLE_TO_SHOW);
		EndDialog(IDABORT);
		return FALSE;
	}

	// refresh display to contents of the automation calculator
	OnRefresh();

	return TRUE;  // return TRUE  unless you set the focus to a control
}
コード例 #12
0
ファイル: DataGridEx.cpp プロジェクト: uesoft/AutoPHS
////////////////////////////////////////////////
//
// 初始化TOOLTIP控件
//
void CDataGridEx::InitToolTipControl()
{
	if(m_RecordCount<0)
	{
		LPUNKNOWN pUnknown;
		HRESULT hr;
		_RecordsetPtr IRecordset;

		pUnknown=GetDataSource();
		
		if(pUnknown==NULL)
			return;

		try
		{
			hr=pUnknown->QueryInterface(__uuidof(Recordset),(void**)&IRecordset);

			pUnknown->Release();

			if(FAILED(hr))
			{
				throw _com_error(hr);
			}

			m_RecordCount=IRecordset->GetRecordCount();
		}
		catch(_com_error &e)
		{
			AfxMessageBox(e.ErrorMessage());
		}
	}

	if(IsWindow(m_ToolTip.GetSafeHwnd()))
		return;

	m_ToolTip.Create(this);
	
	TOOLINFO ToolInfo;

	memset(&ToolInfo,0,sizeof(TOOLINFO));

	ToolInfo.cbSize=sizeof(TOOLINFO);
	ToolInfo.uFlags=TTF_TRACK|TTF_IDISHWND| TTF_ABSOLUTE;
	ToolInfo.hwnd=this->m_hWnd;
	ToolInfo.uId=(UINT)this->m_hWnd;
	ToolInfo.lpszText=LPSTR_TEXTCALLBACK;

	m_ToolTip.SendMessage(TTM_ADDTOOL,0,(LPARAM)&ToolInfo);
}
コード例 #13
0
/**
 * Function name	CImplMsgSink::UnregisterMsgSource
 * Description			
 * @param			LPUNKNOWN lpUnkMsgSource
 * @param			DWORD dwCookie
 * @return			HRESULT 
 * @exception			
 * @see			    CMsgWnd
*/
HRESULT CImplMsgSink::UnregisterMsgSource(LPUNKNOWN lpUnkMsgSource, DWORD dwCookie) 
{
    ASSERT(lpUnkMsgSource != NULL);

    LPUNKNOWN           pUnkSink;
    BOOL                bResult;

    HRESULT hr = InternalQueryInterface((IID*)&IID_IUnknown, (void**)&pUnkSink);
    if(FAILED(hr)) 
    {
        return(hr);
    }

    bResult = AfxConnectionUnadvise(lpUnkMsgSource, IID__ICEMessageEvent, pUnkSink, TRUE, dwCookie);
    pUnkSink->Release();
    return(bResult ? S_OK : E_FAIL);
}
コード例 #14
0
BOOL COleDispatchDriver::CreateDispatch(REFCLSID clsid, COleException* pError)
{
	ASSERT(m_lpDispatch == NULL);

	m_bAutoRelease = TRUE;  // good default is to auto-release

	// create an instance of the object
	LPUNKNOWN lpUnknown = NULL;
	SCODE sc = CoCreateInstance(clsid, NULL, CLSCTX_ALL | CLSCTX_REMOTE_SERVER,
		IID_IUnknown, (LPLP)&lpUnknown);
	if (sc == E_INVALIDARG)
	{
		// may not support CLSCTX_REMOTE_SERVER, so try without
		sc = CoCreateInstance(clsid, NULL, CLSCTX_ALL & ~CLSCTX_REMOTE_SERVER,
			IID_IUnknown, (LPLP)&lpUnknown);
	}
	if (FAILED(sc))
		goto Failed;

	// make sure it is running
	sc = OleRun(lpUnknown);
	if (FAILED(sc))
		goto Failed;

	// query for IDispatch interface
	m_lpDispatch = QUERYINTERFACE(lpUnknown, IDispatch);
	if (m_lpDispatch == NULL)
		goto Failed;

	lpUnknown->Release();
	ASSERT(m_lpDispatch != NULL);
	return TRUE;

Failed:
	RELEASE(lpUnknown);
	if (pError != NULL)
		pError->m_sc = sc;
	TRACE1("Warning: CreateDispatch returning scode = %s.\n",
		AfxGetFullScodeString(sc));
	return FALSE;
}
コード例 #15
0
ファイル: inspectors.cpp プロジェクト: gpg/gpgol
/* Return the MAPI message object of then inspector from a button's
   instance id. */
static LPMESSAGE
get_message_from_button (unsigned long instid, LPDISPATCH *r_inspector)
{
  HRESULT hr;
  LPDISPATCH inspector, obj;
  LPUNKNOWN  unknown;
  LPMESSAGE message = NULL;
  
  if (r_inspector)
    *r_inspector = NULL;
  inspector = get_inspector_from_instid (instid);
  if (inspector)
    {
      obj = get_oom_object (inspector, "get_CurrentItem");
      if (!obj)
        log_error ("%s:%s: error getting CurrentItem", SRCNAME, __func__);
      else
        {
          unknown = get_oom_iunknown (obj, "MAPIOBJECT");
          if (!unknown)
            log_error ("%s:%s: error getting MAPI object", SRCNAME, __func__);
          else
            {
              hr = unknown->QueryInterface (IID_IMessage, (void**)&message);
              if (hr != S_OK || !message)
                {
                  message = NULL;
                  log_error ("%s:%s: error getting IMESSAGE: hr=%#lx",
                             SRCNAME, __func__, hr);
                }
              unknown->Release ();
            }
          obj->Release ();
        }
      if (r_inspector)
        *r_inspector = inspector;
      else
        inspector->Release ();
    }
  return message;
}
コード例 #16
0
ファイル: OLAddrBook.cpp プロジェクト: hackshields/antivirus
	bool COLAddrBook::SessionLogOn(ULONG hWnd, LPCTSTR profile, LPCTSTR pswd, ULONG flags)
	{
		bool bResult = false;
		LPMAPISESSION pSession = NULL;
		HRESULT hr = g_pMAPIEDK->pMAPILogonEx(hWnd, (LPTSTR)profile, (LPTSTR)pswd, flags, &pSession);

		if (pSession)
		{
			LPADRBOOK pAddrBook = NULL;
			if (SUCCEEDED(pSession->OpenAddressBook(NULL, NULL, AB_NO_DIALOG, &pAddrBook)))
			{
				m_initRef->SetAddrBook(pAddrBook);

				// открываем корневой каталог
				ULONG ulObjType = 0;
				LPUNKNOWN pUnk = NULL;
				if (SUCCEEDED(pAddrBook->OpenEntry(0, NULL, NULL, MAPI_BEST_ACCESS, &ulObjType, &pUnk)))
				{
					if (MAPI_ABCONT == ulObjType)
					{
						LPABCONT pContainer = NULL;
						m_pABCont = (LPABCONT)pUnk;
						m_pABCont->AddRef();
						bResult = true;
					}			
				}

				if (pUnk)
					pUnk->Release();
			}

			if (pAddrBook)
				pAddrBook->Release();
		}

		if (pSession)
			pSession->Release();

		return bResult;
	}
コード例 #17
0
ファイル: ex24dView.cpp プロジェクト: jiayuehua/InsideVC
void CEx24dView::OnExceloleLoad() 
{   // if Excel is already running, attach to it, otherwise start it
   LPDISPATCH pDisp;
   LPUNKNOWN pUnk;
   CLSID clsid;
   TRACE("Entering CEx24dView::OnExcelLoad\n");
   BeginWaitCursor();
   ::CLSIDFromProgID(L"Excel.Application.8", &clsid); // from registry
   if(::GetActiveObject(clsid, NULL, &pUnk) == S_OK) {
      VERIFY(pUnk->QueryInterface(IID_IDispatch,
            (void**) &pDisp) == S_OK);
      m_app.AttachDispatch(pDisp);
      pUnk->Release();
      TRACE(" attach complete\n");
  } 
   else {
	   if(!m_app.CreateDispatch("Excel.Application.8")) {
			AfxMessageBox("Excel 97 program not found");
	   }
       TRACE(" create complete\n");
   }
   EndWaitCursor();
}
コード例 #18
0
CDlgIADsSecurityDescriptor::CDlgIADsSecurityDescriptor(LPUNKNOWN pUnk, CWnd* pParent /*=NULL*/)
	: CDialog(CDlgIADsSecurityDescriptor::IDD, pParent)
{
	//{{AFX_DATA_INIT(CDlgIADsSecurityDescriptor)
	//}}AFX_DATA_INIT


	
	HRESULT hr;	
	m_pSecurityDesc = NULL;

	
	hr = pUnk->QueryInterface( IID_IADsSecurityDescriptor, (void **) &m_pSecurityDesc );
	pUnk->Release();

	if ( !SUCCEEDED(hr) )
	{
		AfxMessageBox(_T("Fatal Error! QI for IADsSecurityDescriptor failed"));
		return;
	}
	
	

}
コード例 #19
0
ファイル: OLAddrBook.cpp プロジェクト: hackshields/antivirus
	void COLFolderBase::ExtractChildFolders()
	{
		m_childs.clear();

		if (!m_initRef->Inited())
			return;

		if (!m_pABCont)
			return;

		LPMAPITABLE pChildTable = NULL;
		if (SUCCEEDED(m_pABCont->GetHierarchyTable(0, &pChildTable)))
		{
			SizedSPropTagArray ( 2, sptCols ) = {2, PR_DISPLAY_NAME, PR_ENTRYID};
			LPSRowSet pRowSet = NULL;
			if (SUCCEEDED(g_pMAPIEDK->pHrQueryAllRows(pChildTable, reinterpret_cast<SPropTagArray*>(&sptCols), NULL, NULL, 0, &pRowSet)))
			{
				for (ULONG i = 0; i < pRowSet->cRows; ++i)
				{
					string name;
					if (LPSPropValue pPVN = g_pMAPIEDK->pPpropFindProp(pRowSet->aRow[i].lpProps, pRowSet->aRow[i].cValues, PR_DISPLAY_NAME))
					{
						name = pPVN->Value.lpszA ? pPVN->Value.lpszA : "";
					}

					LPABCONT pChildContainer = NULL;
					if (LPSPropValue pPVE = g_pMAPIEDK->pPpropFindProp(pRowSet->aRow[i].lpProps, pRowSet->aRow[i].cValues, PR_ENTRYID))
					{
						SBinary entry = pPVE->Value.bin;
						ULONG ulObjType = 0;
						LPUNKNOWN pUnk = NULL;

						if (SUCCEEDED(m_pABCont->OpenEntry(entry.cb, (LPENTRYID)entry.lpb, NULL, MAPI_BEST_ACCESS, &ulObjType, &pUnk)))
						{
							if (MAPI_ABCONT == ulObjType)
							{
								pChildContainer = (LPABCONT)pUnk;
								pChildContainer->AddRef();
							}
						}

						if (pUnk)
							pUnk->Release();
					}

					if (pChildContainer)
					{
						m_childs.push_back(TAddrFolderPtr(new COLAddrFolder(name.c_str(), m_initRef, pChildContainer)));
						pChildContainer->Release();
					}
				}

				g_pMAPIEDK->pFreeProws(pRowSet);
				
			}
		}

		if (pChildTable)
			pChildTable->Release();

	}
コード例 #20
0
ファイル: inspectors.cpp プロジェクト: gpg/gpgol
/* Update the crypto info icon.  */
static void
update_crypto_info (LPDISPATCH inspector)
{
  HRESULT hr;
  LPDISPATCH button;
  const char *tooltip = "";
  int iconrc = -1;

  button = get_button (inspector, "GpgOL_Inspector_Crypto_Info");
  if (!button)
    {
      log_error ("%s:%s: Crypto Info button not found", SRCNAME, __func__);
      return;
    }

  if (!is_inspector_in_composer_mode (inspector))
    {
      LPDISPATCH obj;
      LPUNKNOWN unknown;
      LPMESSAGE message = NULL;

      obj = get_oom_object (inspector, "get_CurrentItem");
      if (obj)
        {
          unknown = get_oom_iunknown (obj, "MAPIOBJECT");
          if (!unknown)
            log_error ("%s:%s: error getting MAPI object", SRCNAME, __func__);
          else
            {
              hr = unknown->QueryInterface (IID_IMessage, (void**)&message);
              if (hr != S_OK || !message)
                {
                  message = NULL;
                  log_error ("%s:%s: error getting IMESSAGE: hr=%#lx",
                             SRCNAME, __func__, hr);
                }
              unknown->Release ();
            }
          obj->Release ();
        }
      if (message)
        {
          int is_encrypted = 0;
          int is_signed = 0;
          
          switch (mapi_get_message_type (message))
            {
            case MSGTYPE_GPGOL_MULTIPART_ENCRYPTED:
            case MSGTYPE_GPGOL_OPAQUE_ENCRYPTED:
            case MSGTYPE_GPGOL_PGP_MESSAGE:
              is_encrypted = 1;
              if ( mapi_test_sig_status (message) )
                is_signed = 1;
              break;
            case MSGTYPE_GPGOL:
            case MSGTYPE_SMIME:
            case MSGTYPE_UNKNOWN:
              break;
            default:
              is_signed = 1;
              break;
            }
          
          if (is_signed && is_encrypted)
            {
              tooltip =  _("This is a signed and encrypted message.\n"
                           "Click for more information. ");
              iconrc = IDB_DECRYPT_VERIFY_16;
            }
          else if (is_signed)
            {
              tooltip =  _("This is a signed message.\n"
                           "Click for more information. ");
              iconrc = IDB_VERIFY_16;
            }
          else if (is_encrypted)
            {
              tooltip =  _("This is an encrypted message.\n"
                           "Click for more information. ");
              iconrc = IDB_DECRYPT_16;
            }
          
          message->Release ();
        }
    }

  put_oom_string (button, "TooltipText", tooltip);
  if (iconrc != -1)
    put_oom_icon (button, iconrc, 16);
  put_oom_bool (button, "Visible", (iconrc != -1));
  button->Release ();
}
コード例 #21
0
ファイル: WordObject.cpp プロジェクト: killbug2004/WSProf
HRESULT CWordObject::Release()
{
	HRESULT hr;
	
	if (m_pUnknown == NULL) 
		return S_OK;

	LPUNKNOWN lpUnk = NULL;
	
	if (m_pStrUnknown != NULL)
	{
		hr = CoGetInterfaceAndReleaseStream(m_pStrUnknown, IID_IUnknown, (void**) &lpUnk);
		if (FAILED(hr))
		{
			LOG_WS_ERROR(_T("CoGetInterfaceAndReleaseStream FAILED."));	
		}
	}
	else
	{
		lpUnk = m_pUnknown;
		m_pWordCreator->AddRef(lpUnk);
	}


	try
	{
		m_pUnknown->Release();
		m_pUnknown = NULL;
	}
	catch(...)
	{
		m_pUnknown = NULL;
		LOG_WS_ERROR(_T("m_pUnknown Failed to release"));
	}

	
	if (NULL == lpUnk)
	{
		LOG_WS_ERROR(_T("lpUnk == NULL"));
		return E_FAIL;
	}



	if (m_bUsingCurrentInstance)
	{	
		hr = S_FALSE;
	}
	else if (!IsVisible(lpUnk))
	{
		hr = Quit(lpUnk);
	}
	else
	{
		// If Word is visible, then only quit the cached Word instance if we are sure that
		// there aren't any manually opened documents.  i.e. if the user has opened a document,
		// so that there is a visible instance of Word open while DeltaVw is still open.
		Word::_ApplicationPtr pApp = GetApplicationPtr();

		if( pApp )
		{
			long lNumDocs = pApp->Documents->Count;

			if( lNumDocs <= 0 )
			{
				LOG_WS_INFO(L"No open documents found for the current Word instance.  Quitting Word");

				SetVisible(false);
				hr = Quit(lpUnk);
			}
			else
			{
				LOG_WS_INFO(L"Documents are still open in the current Word instance.  NOT quitting Word");
			}
		}
	}

	if (IsCachingWordEnabled())
		m_pGit->RevokeInterfaceFromGlobal(m_dwSessionCookie);

	try
	{
		if (lpUnk)
		{
			lpUnk->Release();
			lpUnk = NULL;			
		}
	}
	catch(...)
	{
		lpUnk = NULL;	
		LOG_WS_ERROR(_T("m_pUnknown Failed to release"));
	}

	// This is required to stop the DeltaView app tests from hanging
	Sleep(125);
	
	return hr;
}
コード例 #22
0
ファイル: com.hpp プロジェクト: nagoya313/ngy313
void intrusive_ptr_release(LPUNKNOWN com) {
  assert(com);
  com->Release();
}
コード例 #23
0
void
addMenuThroughCom()
{

    AutoCAD::IAcadApplication *pAcad;
    AutoCAD::IAcadMenuBar *pMenuBar;
    AutoCAD::IAcadMenuGroups *pMenuGroups;
    AutoCAD::IAcadMenuGroup *pMenuGroup;
    AutoCAD::IAcadPopupMenus *pPopUpMenus;
    AutoCAD::IAcadPopupMenu *pPopUpMenu;
    AutoCAD::IAcadPopupMenuItem *pPopUpMenuItem;

    HRESULT hr = NOERROR;
    CLSID clsid;
    LPUNKNOWN pUnk = NULL;
    LPDISPATCH pAcadDisp = NULL; 

    hr = ::CLSIDFromProgID(L"AutoCAD.Application", &clsid);
    if (SUCCEEDED(hr))
    {
        if(::GetActiveObject(clsid, NULL, &pUnk) == S_OK)
        {
            if (pUnk->QueryInterface(IID_IDispatch, (LPVOID*) &pAcadDisp) != S_OK)
                return;
            pUnk->Release();
        }
    }
    if (SUCCEEDED(pAcadDisp->QueryInterface(AutoCAD::IID_IAcadApplication,(void**)&pAcad))  ){  
        pAcad->put_Visible(true);
    } else {
        acutPrintf("\nQueryInterface trouble.");
        return;
    }

    pAcad->get_MenuBar(&pMenuBar);
    pAcad->get_MenuGroups(&pMenuGroups);

    pAcad->Release();

    long numberOfMenus;
    pMenuBar->get_Count(&numberOfMenus);
    pMenuBar->Release();

    VARIANT index;
    VariantInit(&index);
    V_VT(&index) = VT_I4;
    V_I4(&index) = 0;

    pMenuGroups->Item(index, &pMenuGroup);
    pMenuGroups->Release();
    
    pMenuGroup->get_Menus(&pPopUpMenus);
    pMenuGroup->Release();

    WCHAR wstrMenuName[256];
    MultiByteToWideChar(CP_ACP, 0, "AsdkComAccess", -1, wstrMenuName, 256); 

    // Enables the menu to be loaded/unloaded with the same command.
    if (!bIsMenuLoaded) {
        pPopUpMenus->Add(wstrMenuName, &pPopUpMenu);

        if (pPopUpMenu != NULL) {

            WCHAR wstrMenuItemName[256];
            MultiByteToWideChar(CP_ACP, 0, "&Add A ComCircle", -1, wstrMenuItemName, 256); 
            WCHAR wstrMenuItemMacro[256];
            MultiByteToWideChar(CP_ACP, 0, "AsdkComCircle ", -1, wstrMenuItemMacro, 256); 

            VariantInit(&index);
            V_VT(&index) = VT_I4;
            V_I4(&index) = 0;
            pPopUpMenu->AddMenuItem(index, wstrMenuItemName, wstrMenuItemMacro, &pPopUpMenuItem);

            VariantInit(&index);
            V_VT(&index) = VT_I4;
            V_I4(&index) = 1;
            pPopUpMenu->AddSeparator(index, &pPopUpMenuItem);

            MultiByteToWideChar(CP_ACP, 0, "Auto&LISP Example", -1, wstrMenuItemName, 256); 
            MultiByteToWideChar(CP_ACP, 0, "(prin1 \"Hello\") ", -1, wstrMenuItemMacro, 256); 

            VariantInit(&index);
            V_VT(&index) = VT_I4;
            V_I4(&index) = 2;
            pPopUpMenu->AddMenuItem(index, wstrMenuItemName, wstrMenuItemMacro, &pPopUpMenuItem);

            VariantInit(&index);
            V_VT(&index) = VT_I4;
            V_I4(&index) = numberOfMenus - 2;
            pPopUpMenu->InsertInMenuBar(index);
    
            pPopUpMenuItem->Release();
            bIsMenuLoaded = true;
        } else {
            acutPrintf("\nMenu not created.");
        }
    } else {
        VariantInit(&index);
        V_VT(&index) = VT_BSTR;
        V_BSTR(&index) = wstrMenuName;
        pPopUpMenus->RemoveMenuFromMenuBar(index);
        
        bIsMenuLoaded = false;
    }

    pPopUpMenus->Release();
}
コード例 #24
0
void
addCircleThroughCom()
{
    AutoCAD::IAcadApplication *pAcad;
    AutoCAD::IAcadDocument *pDoc;
    AutoCAD::IAcadModelSpace *pMSpace;

    HRESULT hr = NOERROR;
    CLSID clsid;
    LPUNKNOWN pUnk = NULL;
    LPDISPATCH pAcadDisp = NULL; 

    hr = ::CLSIDFromProgID(L"AutoCAD.Application", &clsid);
    if (SUCCEEDED(hr))
    {
        if(::GetActiveObject(clsid, NULL, &pUnk) == S_OK)
        {
            if (pUnk->QueryInterface(IID_IDispatch, (LPVOID*) &pAcadDisp) != S_OK)
                return;
            pUnk->Release();
        }
    }
    if (SUCCEEDED(pAcadDisp->QueryInterface(AutoCAD::IID_IAcadApplication,(void**)&pAcad))  ){  
        pAcad->get_ActiveDocument(&pDoc);
        pDoc->get_ModelSpace(&pMSpace);

        pAcad->Release();
        pDoc->Release();

    }


    SAFEARRAYBOUND rgsaBound;
    rgsaBound.lLbound = 0L;
    rgsaBound.cElements = 3;
    long i;
    SAFEARRAY* pStartPoint = NULL;
    pStartPoint = SafeArrayCreate(VT_R8, 1, &rgsaBound);

    i = 0;
    double value = 4.0;
    SafeArrayPutElement(pStartPoint, &i, &value);
    
    i = 1;
    value = 2.0;
    SafeArrayPutElement(pStartPoint, &i, &value);
    
    i = 2;
    value = 0.0;
    SafeArrayPutElement(pStartPoint, &i, &value);
    
    VARIANT pt1;
    pt1.vt = VT_ARRAY | VT_R8;
    pt1.parray = pStartPoint;

    AutoCAD::IAcadCircle *pCircle;
    pMSpace->AddCircle(pt1, 2.0, &pCircle);

    pMSpace->Release();

}
コード例 #25
0
/*!
 @brief このメソッドは WM_INITDIALOG のメッセージに応答して呼び出されます。
*/
BOOL CInspectUsefulToolsDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	// このダイアログのアイコンを設定します。アプリケーションのメイン ウィンドウがダイアログでない場合、
	//  Framework は、この設定を自動的に行います。
	SetIcon(m_hIcon, TRUE);			// 大きいアイコンの設定
	//SetIcon(m_hIcon, FALSE);		// 小さいアイコンの設定

	// メニューの初期化
	InitializeMenuTree();
	InitializeContents();

	// タイトルの設定
	CString strAppName = CString((LPCTSTR)IDS_APP_NAME);
	this->SetWindowText(strAppName);

	CLSID clsid;
	if (CLSIDFromProgID(OLESTR("Excel.Application"), &clsid) == NOERROR){
		// Excel がインストールされている
		LPUNKNOWN lpUnk;
		HRESULT hr;
		LPDISPATCH lpDispatch;
		BOOL bOpenExcel = FALSE;
		if (GetActiveObject(clsid, NULL, &lpUnk) == NOERROR){
			hr = lpUnk->QueryInterface(IID_IDispatch, (LPVOID*)&lpDispatch);
			lpUnk->Release();
			if (hr == NOERROR) {
				//すでにExcelが起動されている状態であればAttachDispatch
				m_inXLApp.AttachDispatch(lpDispatch,TRUE);
				bOpenExcel = TRUE;
			}
		}

		if (m_inXLApp.m_lpDispatch == NULL) {
			bOpenExcel = m_inXLApp.CreateDispatch(clsid);
			m_bOpenXL = TRUE;
		}

		if (bOpenExcel == TRUE) {
			// Excelファイルの初期化
			CWorkbooks inWorkbooks = m_inXLApp.get_Workbooks();
			COleVariant varNull;
			varNull.ChangeType(VT_NULL);

			HRSRC hrSrc = FindResource(AfxGetApp()->m_hInstance, MAKEINTRESOURCE(IDR_MACRO_EXCEL_RCDATA), RT_RCDATA);
			if (hrSrc != NULL) {
				HGLOBAL hGlobal = LoadResource(AfxGetApp()->m_hInstance, hrSrc);

				if (hGlobal != NULL) {
					char *rcData = (char *)LockResource(hGlobal);

					/* リソースサイズの取得 */
					DWORD dwSize = SizeofResource(AfxGetApp()->m_hInstance, hrSrc);

					TCHAR szFilePath[MAX_PATH];
					GetTempPath(MAX_PATH, szFilePath);
					TCHAR szFileName[MAX_PATH];
					GetTempFileName(szFilePath, _T("SubTools_"), 0, szFileName);

					CFile inFile;
					inFile.Open(szFileName, CFile::modeWrite);
					inFile.Write(rcData, dwSize);
					inFile.Close();
					strTempFilePath = szFileName;

					m_inXLBook = inWorkbooks.Open(szFileName
						, varNull, varNull, varNull, varNull, varNull, varNull, varNull, varNull, varNull, varNull, varNull, varNull,varNull, varNull);
					m_bOpenBook = TRUE;
				}
			}
		}
	}

	return TRUE;
}
コード例 #26
0
ファイル: olelink.cpp プロジェクト: jbeaurain/omaha_vs2010
BOOL COleLinkingDoc::Register(COleObjectFactory* pFactory, LPCTSTR lpszPathName)
{
	ASSERT_VALID(this);
	ASSERT(pFactory == NULL ||
		AfxIsValidAddress(pFactory, sizeof(COleObjectFactory)));
	ASSERT(lpszPathName == NULL || AfxIsValidString(lpszPathName));
	ASSERT(m_dwRegister == 0);

	// attach the document to the server
	ASSERT(m_pFactory == NULL || m_pFactory == pFactory);
	m_pFactory = pFactory;

	BOOL bResult = TRUE;

	// create file moniker based on path name
	RELEASE(m_lpMonikerROT);
	m_strMoniker.Empty();
	if (lpszPathName != NULL)
	{
		if (CreateFileMoniker(CStringW(lpszPathName), &m_lpMonikerROT) != S_OK)
			bResult = FALSE;
	}

	// register file moniker as running
	if (m_lpMonikerROT != NULL)
	{
		// see if the object is already running in the ROT
		LPRUNNINGOBJECTTABLE lpROT = NULL;
		VERIFY(GetRunningObjectTable(0, &lpROT) == S_OK);
		ASSERT(lpROT != NULL);
		LPUNKNOWN lpUnk;
		if (lpROT->GetObject(m_lpMonikerROT, &lpUnk) == S_OK)
		{
			// fatal error -- can't register same moniker twice!
			lpUnk->Release();
			RELEASE(m_lpMonikerROT);
			return FALSE;
		}
		// not already running -- so ok to attempt registration
		SCODE sc = lpROT->Register(NULL, (LPUNKNOWN)
			GetInterface(&IID_IUnknown), m_lpMonikerROT, &m_dwRegister);
		lpROT->Release();
		m_strMoniker = lpszPathName;
		if (sc != S_OK)
			bResult = FALSE;
	}

	// update all objects with new moniker
	POSITION pos = GetStartPosition();
	COleClientItem* pItem;
	while ((pItem = GetNextClientItem(pos)) != NULL)
	{
		if (pItem->m_bMoniker)
		{
			ASSERT(pItem->m_lpObject != NULL);
			pItem->m_lpObject->SetMoniker(OLEWHICHMK_CONTAINER,
				m_lpMonikerROT);
		}
	}

	return bResult;
}
コード例 #27
0
ファイル: BaseDialog.cpp プロジェクト: JasonSchlauch/mfcmapi
void CBaseDialog::OnOpenEntryID(_In_opt_ LPSBinary lpBin)
{
	HRESULT			hRes = S_OK;
	if (!m_lpMapiObjects) return;

	CEditor MyEID(
		this,
		IDS_OPENEID,
		IDS_OPENEIDPROMPT,
		10,
		CEDITOR_BUTTON_OK | CEDITOR_BUTTON_CANCEL);

	MyEID.InitPane(0, CreateSingleLinePane(IDS_EID, BinToHexString(lpBin, false), false));

	LPMDB lpMDB = m_lpMapiObjects->GetMDB(); // do not release
	MyEID.InitPane(1, CreateCheckPane(IDS_USEMDB, lpMDB ? true : false, lpMDB ? false : true));

	LPADRBOOK lpAB = m_lpMapiObjects->GetAddrBook(false); // do not release
	MyEID.InitPane(2, CreateCheckPane(IDS_USEAB, lpAB ? true : false, lpAB ? false : true));

	LPMAPISESSION lpMAPISession = m_lpMapiObjects->GetSession(); // do not release
	MyEID.InitPane(3, CreateCheckPane(IDS_SESSION, lpMAPISession ? true : false, lpMAPISession ? false : true));

	MyEID.InitPane(4, CreateCheckPane(IDS_PASSMAPIMODIFY, false, false));

	MyEID.InitPane(5, CreateCheckPane(IDS_PASSMAPINOCACHE, false, false));

	MyEID.InitPane(6, CreateCheckPane(IDS_PASSMAPICACHEONLY, false, false));

	MyEID.InitPane(7, CreateCheckPane(IDS_EIDBASE64ENCODED, false, false));

	MyEID.InitPane(8, CreateCheckPane(IDS_ATTEMPTIADDRBOOKDETAILSCALL, false, lpAB ? false : true));

	MyEID.InitPane(9, CreateCheckPane(IDS_EIDISCONTAB, false, false));

	WC_H(MyEID.DisplayDialog());
	if (S_OK != hRes) return;

	// Get the entry ID as a binary
	LPENTRYID lpEnteredEntryID = NULL;
	LPENTRYID lpEntryID = NULL;
	size_t cbBin = NULL;
	EC_H(MyEID.GetEntryID(0, MyEID.GetCheck(7), &cbBin, &lpEnteredEntryID));

	if (MyEID.GetCheck(9) && lpEnteredEntryID)
	{
		(void)UnwrapContactEntryID((ULONG)cbBin, (LPBYTE)lpEnteredEntryID, (ULONG*)&cbBin, (LPBYTE*)&lpEntryID);
	}
	else
	{
		lpEntryID = lpEnteredEntryID;
	}

	if (MyEID.GetCheck(8) && lpAB) // Do IAddrBook->Details here
	{
		ULONG_PTR ulUIParam = (ULONG_PTR)(void*)m_hWnd;

		EC_H_CANCEL(lpAB->Details(
			&ulUIParam,
			NULL,
			NULL,
			(ULONG)cbBin,
			lpEntryID,
			NULL,
			NULL,
			NULL,
			DIALOG_MODAL)); // API doesn't like unicode
	}
	else
	{
		LPUNKNOWN lpUnk = NULL;
		ULONG ulObjType = NULL;

		EC_H(CallOpenEntry(
			MyEID.GetCheck(1) ? lpMDB : 0,
			MyEID.GetCheck(2) ? lpAB : 0,
			NULL,
			MyEID.GetCheck(3) ? lpMAPISession : 0,
			(ULONG)cbBin,
			lpEntryID,
			NULL,
			(MyEID.GetCheck(4) ? MAPI_MODIFY : MAPI_BEST_ACCESS) |
			(MyEID.GetCheck(5) ? MAPI_NO_CACHE : 0) |
			(MyEID.GetCheck(6) ? MAPI_CACHE_ONLY : 0),
			&ulObjType,
			&lpUnk));

		if (lpUnk)
		{
			LPWSTR szFlags = NULL;
			InterpretNumberAsStringProp(ulObjType, PR_OBJECT_TYPE, &szFlags);
			DebugPrint(DBGGeneric, _T("OnOpenEntryID: Got object (%p) of type 0x%08X = %ws\n"), lpUnk, ulObjType, szFlags);
			delete[] szFlags;
			szFlags = NULL;

			LPMAPIPROP lpTemp = NULL;
			WC_MAPI(lpUnk->QueryInterface(IID_IMAPIProp, (LPVOID*)&lpTemp));
			if (lpTemp)
			{
				WC_H(DisplayObject(
					lpTemp,
					ulObjType,
					otHierarchy,
					this));
				lpTemp->Release();
			}
			lpUnk->Release();
		}
	}

	delete[] lpEnteredEntryID;
} // CBaseDialog::OnOpenEntryID
コード例 #28
0
//----------------------------- FUNCTION -------------------------------------*
BOOL CSheetConfigGSD::InitPropSlaveModules()
{
	HRESULT hr;
	LONG lValue;
//	BOOL bValue;
	LPUNKNOWN pUnknown = NULL;
	// is it a DP-Slave?
	CComQIPtr<IDP_Slave, &IID_IDP_Slave>  pSlave;
	pSlave = m_pUnknown;
	if (pSlave)
	{
		m_pSlaveModule->SetModularType(m_bIsModular);
		if (m_bIsModular)	{
			hr = pSlave->get_MaxModule(&lValue);
			if (SUCCEEDED(hr)) {
				m_pSlaveModule->SetMaxModule(lValue);
			}
			hr = pSlave->get_MaxInputLen(&lValue);
			if (SUCCEEDED(hr)) {
				m_pSlaveModule->SetMaxInputLen(lValue);
			}
			hr = pSlave->get_MaxOutputLen(&lValue);
			if (SUCCEEDED(hr)) {
				m_pSlaveModule->SetMaxOutputLen(lValue);
			}
			hr = pSlave->get_MaxDataLen(&lValue);
			if (SUCCEEDED(hr)) {
				m_pSlaveModule->SetMaxDataLen(lValue);
			}
		}
		else	{
				m_pSlaveModule->SetMaxModule(0x7FFFFFFF);
				m_pSlaveModule->SetMaxInputLen(0);
				m_pSlaveModule->SetMaxOutputLen(0);
				m_pSlaveModule->SetMaxDataLen(0);
		}

		BSTR	sName = NULL;
		CComQIPtr<IEnumUnknown, &IID_IEnumUnknown>    pEnumModules;
        int modid = 0;

		hr = pSlave->CreateModuleEnumerator(&pUnknown);
		if (SUCCEEDED(hr))
		{
			pEnumModules = pUnknown;
			pUnknown->Release();
			if (pEnumModules)
			{
				ULONG   ulFetched = 0;
				// enumerate thru modules!
				while(pEnumModules->Next(1, &pUnknown, &ulFetched) == S_OK)
				{
					CComQIPtr<IModule, &IID_IModule>    pModule;
					pModule = pUnknown;
					pUnknown->Release();
					if (pModule)
					{
						// print module data
						hr = pModule->get_ModName(&sName);
						if (SUCCEEDED(hr)) {
							CDP_Module* pNewModule = new CDP_Module(modid++);
							pNewModule->SetModuleName(sName);
							LONG lVal;
							if (SUCCEEDED(pModule->get_LenUserParams(&lVal)))
								pNewModule->SetUserPrmLen(lVal);
                            GetAndSaveConfigBytes(pModule, pNewModule);
							m_pSlaveModule->AddNewModule(pNewModule);
							::SysFreeString(sName);

							BOOL    bHasExtUserParam = FALSE;
							hr = pModule->get_HasExtUserParam(&bHasExtUserParam);
							if (SUCCEEDED(hr) && bHasExtUserParam) {
								hr = pModule->CreateExtUserParamEnumerator(&pUnknown);
								if (SUCCEEDED(hr))
								{
									CComQIPtr<IEnumUnknown, &IID_IEnumUnknown>    pEnum;
									pEnum = pUnknown;
									pUnknown->Release();
									if (pEnum == NULL) {
										return E_NOINTERFACE;
									}
									ULONG   ulFetched = 0;
									IUnknown* pUnk = NULL;
									HRESULT   hr = S_FALSE;

									// enumerate thru ext user params!
									while (pEnum->Next(1, &pUnk, &ulFetched) == S_OK)
									{
										CComQIPtr<IExtUserParam, &IID_IExtUserParam>    pParam;
										pParam = pUnk;
										pUnk->Release();
										if (pParam)
										{
											ExtParam* pExtParam = new ExtParam();
											GetExtUserParams(pParam, pExtParam);
											pNewModule->AddExtParamDef(pExtParam);
										}
									}
								}
							}
						}
					}
				}
			}
		}
 	}

	return TRUE;
}
コード例 #29
0
ファイル: com.hpp プロジェクト: nagoya313/ngy313
 void operator ()(LPUNKNOWN com) const {
   assert(com);
   com->Release();
 }
コード例 #30
0
void CTemplateWizardDialog::DocumentComplete(LPDISPATCH pDisp, VARIANT* URL)
{
	UNUSED_ALWAYS(pDisp);
//	ASSERT(V_VT(URL) == VT_BSTR);

	CString str(V_BSTR(URL));

	// Load in the new file...
    HRESULT       hr;
    LPUNKNOWN     pUnkContainedBrowser = NULL;
    LPUNKNOWN     pUnkDispParam = NULL;
    IStream       *pStream = NULL;
    HGLOBAL       hHTMLText;
	CComPtr<IDispatch> pDispDocument;
//	HWND shellWnd;
//	HWND ieWnd;

    // Test for valid pointers.
    if (!m_pBrowserApp || !pDisp)
        goto CleanUp;

    // To test object equality, use COM identity rules: query both 
    // pointers for IUnknown and compare them.
    hr = m_pBrowserApp->QueryInterface(IID_IUnknown, 
        (void**)&pUnkContainedBrowser);
    if (hr)
        goto CleanUp;

    // Query the passed-in IDispatch for IUnknown.
    hr = pDisp->QueryInterface(IID_IUnknown, 
        (void**)&pUnkDispParam);
    if (hr)
        goto CleanUp;

    // If they're unequal, the event is for a subframe and we're not
    // interested.
    if (pUnkContainedBrowser != pUnkDispParam)
        goto CleanUp;

    // As a further check, make sure the URL is "about:blank".
    if (str == "about:blank")
	{
		// The string is about:blank.  This means load the correct page.
		LONG len = (LONG)m_htmlFile.GetLength();
		BYTE* data = m_htmlFile.Detach();
		hHTMLText = GlobalAlloc(GPTR, len + 1);
		if (!hHTMLText)
			goto CleanUp;

		memcpy((CHAR *)hHTMLText, (char*)data, len);
		*(char*)((char*)hHTMLText + len) = 0;

		free(data);

		hr = ::CreateStreamOnHGlobal(hHTMLText, TRUE, &pStream);
		if (hr)
			goto CleanUp;

		// Call the helper function to load the WebOC from the stream.
		//
		hr = LoadWebOCFromStream(m_pBrowserApp, pStream);

		goto CleanUp;
	}
	
/*	// Set the focus to the right window.
	shellWnd = ::FindWindowEx(m_wndBrowser.GetSafeHwnd(), NULL, "Shell DocObject View", NULL);
	ieWnd = ::FindWindowEx(shellWnd, NULL, "Internet Explorer_Server", NULL);
	::SetFocus(ieWnd);
*/
	// Set to the first available input field.
	m_pBrowserApp->get_Document(&pDispDocument);

	if (pDispDocument)
	{
		CComQIPtr<IHTMLDocument2, &IID_IHTMLDocument2> pDocument(pDispDocument);

		// Get all of the HTML elements.
		CComPtr<IHTMLElementCollection> pElements;
		pDocument->get_all(&pElements);

		CComVariant nullVariant;
		CComPtr<IDispatch> pDispFirstElement;

		// Now get the INPUT elements.
		CComPtr<IDispatch> pDispInputElements;
		pElements->tags(CComVariant("INPUT"), &pDispInputElements);
		if (pDispInputElements)
		{
			CComQIPtr<IHTMLElementCollection, &IID_IHTMLElementCollection> pInputElements(pDispInputElements);
			if (pInputElements)
			{
				long count;
				pInputElements->get_length(&count);

				for (int i = 0; i < count; i++)
				{
					// Get the element, if it exists.
					CComPtr<IDispatch> pDispElement;
					pInputElements->item(CComVariant(i), nullVariant, &pDispElement);
					if (!pDispElement)
						continue;

					CComQIPtr<IHTMLElement, &IID_IHTMLElement> pElement(pDispElement);
					if (!pElement)
						continue;		//??

					CComBSTR bstrID;
					pElement->get_id(&bstrID);

					CComQIPtr<IHTMLInputElement, &IID_IHTMLInputElement> pInputElement(pElement);
					if (!pInputElement)
						continue;		//??

					// Get the type.
					CComBSTR bstrType;
					pInputElement->get_type(&bstrType);
					CString strType(bstrType);
					
					CString id(bstrID);
					CString value;
					if (!m_params.Lookup(id, value))
					{
						value = m_code.GetEntry(id);
					}

					if (strType == "text")
					{
						value = g_wwhizTemplateManager->ParseCode(value, NULL, &m_code);
						pInputElement->put_value(CComBSTR(value));

						if (!pDispFirstElement)
							pDispFirstElement = pDispElement;
					}
					else if (strType == "checkbox")
					{
						pInputElement->put_checked(value == "1" ? VARIANT_TRUE : VARIANT_FALSE);
					}
					else if (strType == "radio")
					{
						pInputElement->put_checked(value == "1" ? VARIANT_TRUE : VARIANT_FALSE);
					}
					else if (strType == "file")
					{
						CComQIPtr<IHTMLInputFileElement,
							&IID_IHTMLInputFileElement> pInputFileElement(pElement);
						if (!pInputFileElement)
							continue;		//??

						value = g_wwhizTemplateManager->ParseCode(value, NULL, &m_code);
						pInputFileElement->put_value(CComBSTR(value));

						if (!pDispFirstElement)
							pDispFirstElement = pDispElement;
					}
				}
			}
		}

		// Now get the SELECT elements.
		CComPtr<IDispatch> pDispSelectElements;
		pElements->tags(CComVariant("SELECT"), &pDispSelectElements);
		if (pDispSelectElements)
		{
			CComQIPtr<IHTMLElementCollection, &IID_IHTMLElementCollection> pSelectElements(pDispSelectElements);
			if (pSelectElements)
			{
				long count;
				pSelectElements->get_length(&count);

				for (int i = 0; i < count; i++)
				{
					// Get the element, if it exists.
					CComPtr<IDispatch> pDispElement;
					pSelectElements->item(CComVariant(i), nullVariant, &pDispElement);
					if (!pDispElement)
						continue;

					CComQIPtr<IHTMLElement, &IID_IHTMLElement> pElement(pDispElement);
					if (!pElement)
						continue;		//??

					CComBSTR bstrID;
					pElement->get_id(&bstrID);

					CComQIPtr<IHTMLSelectElement, &IID_IHTMLSelectElement> pSelectElement(pElement);
					if (!pSelectElement)
						continue;		//??

					// Get the type.
					CComBSTR bstrType;
					pSelectElement->get_type(&bstrType);
					CString strType(bstrType);
					
					CString id(bstrID);
					CString value;
					if (!m_params.Lookup(id, value))
					{
						value = m_code.GetEntry(id);
					}

					// This is the only way I can figure out to do this!

					// Match the name.
					long optionCount;
					pSelectElement->get_length(&optionCount);
					int j;
					for (j = 0; j < optionCount; j++)
					{
						// Get the item at the index.
						CComPtr<IDispatch> pDispOptionElement;
						pSelectElement->item(CComVariant(j), nullVariant, &pDispOptionElement);
						if (pDispOptionElement)
						{
							CComQIPtr<IHTMLOptionElement, &IID_IHTMLOptionElement> pOptionElement(pDispOptionElement);

							CComBSTR bstrItem;
							pOptionElement->get_text(&bstrItem);
							CString strItem(bstrItem);
							if (value == strItem)
							{
								pSelectElement->put_selectedIndex(j);
								break;
							}
						}
					}

					if (j == optionCount)
					{
						pSelectElement->put_selectedIndex(0);
					}
				}
			}
		}

		if (pDispFirstElement)
		{
			CComQIPtr<IHTMLControlElement, &IID_IHTMLControlElement> pHtmlElement(pDispFirstElement);
			pHtmlElement->focus();
			CComQIPtr<IHTMLInputTextElement, &IID_IHTMLInputTextElement> pElement(pDispFirstElement);
			if (pElement)
			{
				pElement->select();
			}
		}
	}

CleanUp:
    if (pStream)
        pStream->Release();
    if (pUnkContainedBrowser)
        pUnkContainedBrowser->Release();
    if (pUnkDispParam)
        pUnkDispParam->Release();

	if (!m_asciiFilename.IsEmpty())
	{
		_unlink(m_asciiFilename);
		m_asciiFilename.Empty();
	}
}