Example #1
0
int CALLBACK DirList_CompareProcRw(LPARAM lp1,LPARAM lp2,LPARAM lFlags)
{

  HRESULT hr;
  int result;

  LPLV_ITEMDATA lplvid1 = (LPLV_ITEMDATA)lp1;
  LPLV_ITEMDATA lplvid2 = (LPLV_ITEMDATA)lp2;

  hr = (lplvid1->lpsf->lpVtbl->CompareIDs(
                                 lplvid1->lpsf,
                                 lFlags,
                                 lplvid1->pidl,
                                 lplvid2->pidl));

  result = -(short)(SCODE_CODE(GetScode(hr)));

  if (result != 0)
    return(result);

  hr = (lplvid1->lpsf->lpVtbl->CompareIDs(
                                 lplvid1->lpsf,
                                 0,
                                 lplvid1->pidl,
                                 lplvid2->pidl));

  result = -(short)(SCODE_CODE(GetScode(hr)));

  return(result);

}
Example #2
0
HRESULT CIMacroScriptImp :: DestroyStorage()
{

CEnumMacroScripts *pEn = NULL;
HRESULT hr = m_pMacroScripts -> GetEnum (&pEn);
	if (FAILED(hr)) return hr;	
	
CObArray *pA = pEn -> GetArray ();	
	pEn -> Release();

    if (0 != ULONG(pA -> GetSize())) return hr; 

	USES_CONVERSION;

LPSTORAGE pIStorage = NULL;
	
	if (NULL == DEX_GetProjectStorage (pIStorage)) {
		if (m_pIRootStorage) {
			hr = m_pIRootStorage -> DestroyElement(A2OLE("MacroScripts"));
			if (FAILED(hr) && GetScode(hr) != STG_E_FILENOTFOUND) return hr;

			hr = m_pIRootStorage -> Commit(STGC_DEFAULT);
			if (FAILED(hr)) return hr;
		}
	}
	else {
		hr = m_pMacroScripts -> GetIPersistStorage() -> HandsOffStorage();
		if (FAILED(hr)) { pIStorage -> Release(); return hr; }

		hr = pIStorage -> DestroyElement(A2OLE("MacroScripts"));
		pIStorage -> Release();
	}

return hr;
}
Example #3
0
BOOL PASCAL COleClientItem::CanPaste()
{
    if (afxData.bWin31)
    {
        // We must use OleQueryCreateFromData on Win32s
        BOOL bCanPaste = FALSE;
        LPDATAOBJECT lpDataObject;
        if (::OleGetClipboard(&lpDataObject) == S_OK)
        {
            ASSERT(lpDataObject != NULL);
            SCODE sc = GetScode(::OleQueryCreateFromData(lpDataObject));
            bCanPaste = !FAILED(sc) && sc != S_FALSE;
            lpDataObject->Release();
        }
        return bCanPaste;
    }
    else
    {
        // it is faster and more reliable to use the Windows clipboard
        //  APIs instead of OleQueryCreateFromData.
        return IsClipboardFormatAvailable(_oleData.cfEmbedSource) ||
               IsClipboardFormatAvailable(_oleData.cfEmbeddedObject) ||
               IsClipboardFormatAvailable(_oleData.cfFileName) ||
               IsClipboardFormatAvailable(_oleData.cfFileNameW) ||
               IsClipboardFormatAvailable(CF_METAFILEPICT) ||
               IsClipboardFormatAvailable(CF_DIB) ||
               IsClipboardFormatAvailable(CF_BITMAP) ||
               (IsClipboardFormatAvailable(_oleData.cfOwnerLink) &&
                IsClipboardFormatAvailable(_oleData.cfNative));
    }
}
Example #4
0
BOOL PASCAL COleClientItem::CanPasteLink()
{
    if (afxData.bWin31)
    {
        // We must use OleQueryLinkFromData on Win32s
        BOOL bCanPasteLink = FALSE;
        LPDATAOBJECT lpDataObject;
        if (::OleGetClipboard(&lpDataObject) == S_OK)
        {
            ASSERT(lpDataObject != NULL);
            SCODE sc = GetScode(::OleQueryLinkFromData(lpDataObject));
            bCanPasteLink = !FAILED(sc) && sc != S_FALSE;
            lpDataObject->Release();
        }
        return bCanPasteLink;
    }
    else
    {
        // it is faster and more reliable to use the Windows clipboard
        //  APIs instead of OleQueryCreateFromData.
        return IsClipboardFormatAvailable(_oleData.cfLinkSource) ||
               IsClipboardFormatAvailable(_oleData.cfFileName) ||
               IsClipboardFormatAvailable(_oleData.cfFileNameW) ||
               IsClipboardFormatAvailable(_oleData.cfObjectLink);
    }
}
Example #5
0
void CXLAutomation::ShowException(LPOLESTR szMember, HRESULT hr, EXCEPINFO *pexcep, unsigned int uiArgErr)
{
	TCHAR szBuf[512];
	
	switch (GetScode(hr)) 
	{
		case DISP_E_UNKNOWNNAME:
			wsprintf(szBuf, "%s: Unknown name or named argument.", szMember);
			break;
	
		case DISP_E_BADPARAMCOUNT:
			wsprintf(szBuf, "%s: Incorrect number of arguments.", szMember);
			break;
			
		case DISP_E_EXCEPTION:
			wsprintf(szBuf, "%s: Error %d: ", szMember, pexcep->wCode);
			if (pexcep->bstrDescription != NULL)
				lstrcat(szBuf, (char*)pexcep->bstrDescription);
			else
				lstrcat(szBuf, "<<No Description>>");
			break;
			
		case DISP_E_MEMBERNOTFOUND:
			wsprintf(szBuf, "%s: method or property not found.", szMember);
			break;
		
		case DISP_E_OVERFLOW:
			wsprintf(szBuf, "%s: Overflow while coercing argument values.", szMember);
			break;
		
		case DISP_E_NONAMEDARGS:
			wsprintf(szBuf, "%s: Object implementation does not support named arguments.",
						szMember);
		    break;
		    
		case DISP_E_UNKNOWNLCID:
			wsprintf(szBuf, "%s: The locale ID is unknown.", szMember);
			break;
		
		case DISP_E_PARAMNOTOPTIONAL:
			wsprintf(szBuf, "%s: Missing a required parameter.", szMember);
			break;
		
		case DISP_E_PARAMNOTFOUND:
			wsprintf(szBuf, "%s: Argument not found, argument %d.", szMember, uiArgErr);
			break;
			
		case DISP_E_TYPEMISMATCH:
			wsprintf(szBuf, "%s: Type mismatch, argument %d.", szMember, uiArgErr);
			break;

		default:
			wsprintf(szBuf, "%s: Unknown error occured.", szMember);
			break;
	}
	
// comment out in automation	MessageBox(NULL, szBuf, "OLE Error", MB_OK | MB_ICONSTOP);

}
Example #6
0
void CNetscapeCntrItem::OnActivate()
{
	char * pSource = NULL;
	const char* ptr;
	LPDISPATCH pdisp;
	HRESULT hr;
	int _convert;
	if (m_lpObject->QueryInterface(IID_IDispatch, (void**)&pdisp) == S_OK){
#ifdef XP_WIN32
		LPCOLESTR lpOleStr = T2COLE("SaveAs");
		hr = pdisp->GetIDsOfNames(IID_NULL, (unsigned short **)&lpOleStr, 1, LOCALE_USER_DEFAULT, &m_idSavedAs);
		pdisp->Release();
		if (hr == S_OK)	
			m_bCanSavedByOLE = TRUE;
		else
			m_idSavedAs = DISPID_UNKNOWN;
#else
			m_idSavedAs = DISPID_UNKNOWN;
#endif
	}

	const char* ptr1 = m_csAddress; 
	if (NET_IsLocalFileURL((char*)ptr1)) {
		XP_ConvertUrlToLocalFile(m_csAddress, &pSource);
		m_csDosName = *pSource;  // pick up the drive name.
		m_csDosName += ":";
		m_csDosName += strchr(pSource, '\\');  // pick up the real file name.
		ptr = m_csDosName;	 
		FE_ConvertSpace((char*)ptr);
		XP_FREE(pSource);
	}

	// the object does not support ole automation, try to find out if this is a storagefile, so
	// we can use OLESave().
	if (!m_bCanSavedByOLE) {
#ifdef XP_WIN32		// we will only want to handle saving when the object had storage file.
		int _convert;
		LPCOLESTR lpsz = A2CW(m_csDosName);
		if (StgIsStorageFile(lpsz) == S_OK) 
			m_bCanSavedByOLE = TRUE;
#else                       
		HRESULT sc1 = StgIsStorageFile(m_csDosName);
		if (GetScode(sc1) == S_OK) 
			m_bCanSavedByOLE = TRUE;
#endif
		}

	CGenericView* pView = GetActiveView();
	CFrameGlue *pFrameGlue = pView->GetFrame();
	if(pFrameGlue != NULL)	{
		m_bLocationBarShowing = pFrameGlue->GetChrome()->GetToolbarVisible(ID_LOCATION_TOOLBAR);
	}

	COleClientItem::OnActivate();
}
Example #7
0
STDMETHODIMP CIMacroScriptImp :: DelScript (LPCSTR pcName)
{                             
	ASSERT(pcName);

CMacro *pM = NULL;		
CString strMacroName = pcName;
CEnumMacroScripts *pEn = NULL;

HRESULT hr = m_pMacroScripts -> GetEnum (&pEn);
	if (FAILED(hr)) return hr; 		

// alten schon geöffneten Stream schliessen,
// Objekte aus dem Enumerator loeschen
bool fNew = false;
	hr = pEn -> DelItem (strMacroName, &fNew);
	if (FAILED(hr)) {
		pEn -> Release(); return hr;
	}
	
bool fNotCommit = false;

	//  für COMMIT(), wenigstens einen mit Commit() finden	
	while (S_OK == pEn -> Next (1, &pM, NULL) && fNotCommit == false) {
			fNotCommit = pM -> GetIMacros() -> GetNotCommit();
			if (fNotCommit) break;
	}

	pEn -> Release();

// bei neuem Macro UND kein anderer gespeicherter vorhanden, Commit() nicht nötig
// Commit wurde gesetzt, als der jetzt zu löschende gespeichert wurde

	if (fNew == true && fNotCommit == false) 
		m_fNotCommit = false;			
	else {
		// Löschen beendet, aber noch COMMIT()
		DEX_SetDirtyGeoDB(1);
		m_fNotCommit = true;
	}

LPSTORAGE pIStorage;
	hr = m_pMacroScripts -> GetIPersistStorage() -> GetStorage(&pIStorage);
	if (FAILED(hr)) return hr;	

// Stream vom Storage loeschen, wenn vorhanden
	USES_CONVERSION;
	hr = pIStorage -> DestroyElement (A2OLE(strMacroName));
	pIStorage -> Release();
	if (FAILED(hr) && GetScode(hr) != STG_E_FILENOTFOUND)
		return hr;

return NOERROR;
}
Example #8
0
HRESULT MakeRootStorage(LPSTORAGE *ppIStorage, LPCSTR pPathName)
{           
HRESULT hr = NOERROR;

DWORD dwMode = STGM_READWRITE | STGM_SHARE_EXCLUSIVE | 
				STGM_TRANSACTED ;

char *pNameToUse = new char [_MAX_PATH];

LPSTORAGE pIStorage = *ppIStorage;
	
	if (NULL == pNameToUse || NULL == pPathName)
		return ResultFromScode(E_FAIL);
	
	// alte ProjektStruktur, eigenes DocFile erzeugen/öffnen  
	// erstellt Pfadnamen
	hr = MakeFileName (pPathName, pNameToUse, "str");
	if (FAILED(hr))			
		return hr;
		
// Funktionen machen Addref(), Release() im Destruktor (Memberpointer Rootstorage)
	USES_CONVERSION;
	hr = StgOpenStorage (A2OLE(pNameToUse), NULL, dwMode, 0, 0, &pIStorage);
	if (FAILED(hr)) {
		if (GetScode(hr) == STG_E_FILENOTFOUND) {
		// neu anlegen
			dwMode |= STGM_CREATE;

			hr = StgCreateDocfile (A2OLE(pNameToUse), dwMode, 0, &pIStorage);
			delete (pNameToUse);
			if (FAILED(hr)) return hr;
				
			// GUID reinschreiben (Kontrollmöglichkeit)
			hr = WriteClassStg (pIStorage, CLSID_ScriptContainer);				
			if (FAILED(hr)) {
				pIStorage -> Release();
				return hr;
		    }
		}
		else {
		    delete (pNameToUse);
		    return hr;
		}
	} else delete (pNameToUse);

	hr = TestclsID (pIStorage, CLSID_ScriptContainer);
	if (FAILED(hr)) { pIStorage -> Release(); return hr; }

	*ppIStorage = pIStorage;

	return NOERROR;
}
Example #9
0
int CALLBACK CCJShellTree::TreeViewCompareProc(LPARAM lparam1, LPARAM lparam2, LPARAM /*lparamSort*/)
{
    LPTVITEMDATA lptvid1=(LPTVITEMDATA)lparam1;
    LPTVITEMDATA lptvid2=(LPTVITEMDATA)lparam2;
    HRESULT   hr;

    hr = lptvid1->lpsfParent->CompareIDs(0, lptvid1->lpi, lptvid2->lpi);

    if (FAILED(hr))
       return 0;

    return (short)SCODE_CODE(GetScode(hr));
}
Example #10
0
int CALLBACK CMyTreeView::CompareProc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
{
    UNREFERENCED_PARAMETER(lParamSort);
    TreeItemData* pItem1 = (TreeItemData*)lParam1;
    TreeItemData* pItem2 = (TreeItemData*)lParam2;
    HRESULT hr;
    hr = pItem1->GetParentFolder().CompareIDs(0, pItem1->GetRelCpidl(), pItem2->GetRelCpidl());

    if (FAILED(hr))
        return 0;

    return (short)SCODE_CODE(GetScode(hr));
}
Example #11
0
HRESULT MakeSubStorage(LPSTORAGE pIRootStorage, 
						LPSTORAGE *ppISubStorage,
						const CString &strStorName, 
						bool &fNew, bool fDirect, CLSID clsID)
{       
LPSTORAGE pIStorage;
HRESULT hr;                                                     

DWORD dw = 0;

DWORD dwMode =	STGM_READWRITE | 
				STGM_SHARE_EXCLUSIVE ;	

	if (fDirect) dwMode = dwMode | STGM_DIRECT;
	else dwMode = dwMode | STGM_TRANSACTED;

	if (NULL == pIRootStorage) 	                   
		return ResultFromScode(STG_E_INVALIDPOINTER);

	USES_CONVERSION;
	hr = pIRootStorage -> OpenStorage (	A2OLE(strStorName), 
										NULL, dwMode, NULL,
										0, &pIStorage);
	if (FAILED(hr)) {
		if (STG_E_FILENOTFOUND == GetScode(hr)) {
			hr = pIRootStorage -> CreateStorage (	A2OLE(strStorName), 
													dwMode, 0, 0, &pIStorage);
			if (SUCCEEDED(hr)) {
				hr = WriteClassStg (pIStorage, clsID);
				fNew = true;
			}
			else {
				*ppISubStorage = NULL;
				return hr;
			}
		}
		else {
			*ppISubStorage = NULL;
			return hr;
		}
	}
						
	hr = TestclsID (pIStorage, clsID);
	if (FAILED(hr)) { pIStorage -> Release(); return hr; }
	
	*ppISubStorage = pIStorage;
	
return NOERROR;
} 
Example #12
0
HRESULT CAVIFileRemote::Create(const CLSID& rclsid, const IID& riid, void **ppv) {
	CAVIFileRemote *pAVIFileRemote;
	HRESULT hresult;

	_RPT0(0,"CAVIFileRemote::Create()\n");

	pAVIFileRemote = new CAVIFileRemote(rclsid);

	if (!pAVIFileRemote) return ResultFromScode(E_OUTOFMEMORY);

	hresult = pAVIFileRemote->QueryInterface(riid, ppv);
	pAVIFileRemote->Release();
	if (FAILED(GetScode(hresult))) {
		_RPT0(0,"failed!\n");
	}

	_RPT0(0,"CAVIFileRemote::Create() exit\n");

	return hresult;
}
int CALLBACK COXShellNamespaceNavigator::CompareObjectsProc(LPARAM lParam1, 
															LPARAM lParam2, 
															LPARAM lParamSort)
{
#if defined (_WINDLL)
#if defined (_AFXDLL)
	AFX_MANAGE_STATE(AfxGetAppModuleState());
#else
	AFX_MANAGE_STATE(AfxGetStaticModuleState());
#endif
#endif

	UNREFERENCED_PARAMETER(lParamSort);

    LPNAMESPACEOBJECT lpFolder1=(LPNAMESPACEOBJECT)lParam1;
    LPNAMESPACEOBJECT lpFolder2=(LPNAMESPACEOBJECT)lParam2;

	ASSERT(lpFolder1->lpsfParent==lpFolder2->lpsfParent);

	// Use IShellBrowser::CompareIDs method to compare two folders.
	// The first argument have to be zero.
	// If this method is successful, the CODE field of the status code (SCODE) 
	// contains one of the following values: 
	//		Less than zero		-	The first item should precede the second 
	//								(pidl1 < pidl2).  
	//		Greater than zero	-	The first item should follow the second 
	//								(pidl1 > pidl2).  
	//		Zero				-	The two items are the same (pidl1 = pidl2).  
	//
	// If this method is unsuccessful, it returns an OLE-defined error code. 
	HRESULT hResult=lpFolder1->lpsfParent->
		CompareIDs(0,lpFolder1->lpRelativeIDL,lpFolder2->lpRelativeIDL);

	// if above method failed let's take it as items are equal
    if(FAILED(hResult))
       return 0;

	// return CODE field of status code of result value
    return (short)SCODE_CODE(GetScode(hResult));
}
Example #14
0
STDMETHODIMP CIMacroScriptImp :: GetScriptInfo (LPCSTR pcName, 
												DWORD *pdwInfo) 
{
	ASSERT(pcName);

CMacro *pM = NULL;		
CEnumMacroScripts *pEn = NULL;

HRESULT hr = m_pMacroScripts -> GetEnum (&pEn);
	if (FAILED(hr)) return hr; 		
		
// pMakro -> AddRef(), wenn aufindbar !!!
	hr = pEn -> FindByName (pcName, &pM);
	pEn -> Release();
	
	if (FAILED(hr) || S_FALSE == GetScode(hr)) 	return hr;

LPSTREAM pIStream = NULL;
	
	if(m_pIStream) {
		m_pIStream -> Release(); m_pIStream = NULL;
	}

CString str = pcName;
								// ADDREF()
	hr = OpenOrCreateStream(str, &m_pIStream);
	if(FAILED(hr)) {
		pM -> Release(); return hr;
	}

ebFILEHEADER Head;
	hr = pM -> GetIPersistStream() -> LoadHeader (m_pIStream, &Head);
	pM -> Release();			// kein Header
	if (FAILED(hr)) return hr; 

// Header, aber kein Code
	*pdwInfo = GetScriptInfo (&Head);

return hr;
} 
Example #15
0
void NEAR MethodError
(
    HRESULT res
)
{
    ERR err;
    int i;
    CHAR * szFormat;

    Assert(FAILED(res));		// should only be called if error
    
    scodeErrCur = GetScode(res);	// get scode from the hresult

    // pick appripriate error format string, depending on whether we are
    // reading an imported type library, or writing one.
    if (fDoingOutput)
        szFormat = szFmtErrOutput;
    else
        szFormat = szFmtErrImportlib;

    // find err constant that matches this scode, if any
    for (i = 0; ;i++)
	{
	    if (rgTypelibScodes[i] == scodeErrCur)
		{   // found error in mapping table.  Add table index to
		    // first TYPELIB.DLL error to get error constant.
		    err = (ERR)(i + OERR_TYPE_E_IOERROR);
		    break;
		}
	    else if (rgTypelibScodes[i] == S_FALSE)
		{   // not in our mapping table -- use general error
		    err = OERR_TYPEINFO;
		    szFormat = szFmtErrUnknown;
		    break;
		}
	}

    ItemError(szFormat, lpszItemCur, err);
}
/* #FN#
   Callback routine for sorting the tree */
int CALLBACK
/* #AS#
   A negative value if the first item should precede the second,
   a positive value if the first item should follow the second,
   or zero if the two items are equivalent */
CShellTree::
TreeViewCompareProc(
	LPARAM lparam1,   /* #IN# */
	LPARAM lparam2,   /* #IN# */
	LPARAM lparamSort /* #IN# */
)
{
	LPTVITEMDATA lptvid1 = (LPTVITEMDATA)lparam1;
	LPTVITEMDATA lptvid2 = (LPTVITEMDATA)lparam2;

	HRESULT hr = lptvid1->lpsfParent->CompareIDs( 0, lptvid1->lpi, lptvid2->lpi );

	if( FAILED(hr) )
		return 0;

	return (short)SCODE_CODE(GetScode( hr ));

} /* #OF# CShellTree::TreeViewCompareProc */
/**
 * Checks whether the given string is a correct identifier
 *
 * @param           
 * @return          
 * @exception       -
 * @see             
*/
bool CProjectWizardData::CheckIdentifier (CString strIdentifier, int iResourceIdIdentifierType)
{
    HRESULT hr;
    CString strIdentifierType;
    CString strMessage;

    hr = UTIL_CheckIdentifier (strIdentifier);

    if (SUCCEEDED (hr))
        return (true);

    strIdentifierType.LoadString (iResourceIdIdentifierType);

    switch (GetScode (hr))
    {
    case E_UTIL_ID_SYNTAX:
        strMessage.Format (IDS_ERR_IDENTIFIER_SYNTAX, strIdentifierType, strIdentifier);
        AfxMessageBox (strMessage);
    break;

    case E_UTIL_ID_IS_KEYWORD:
        strMessage.Format (IDS_ERR_IDENTIFIER_IS_KEYWORD, strIdentifierType, strIdentifier);
        AfxMessageBox (strMessage);
    break;

    case E_UTIL_ID_TOO_LONG:
        strMessage.Format (IDS_ERR_IDENTIFIER_TOO_LONG, strIdentifierType, strIdentifier);
        AfxMessageBox (strMessage);
    break;

    default:
    break;
    };

    return (false);
}
Example #18
0
STDMETHODIMP CIMacroScriptImp :: SetScript (LPCSTR pcName, 
											LPSTR pText, ebHCODE hCode, 
											DWORD dwSaveFlag) 
{
	ASSERT(pcName);

CString strMacroName = pcName;
CMacro *pM = NULL;
CEnumMacroScripts *pEn = NULL;
HRESULT hr = m_pMacroScripts -> GetEnum (&pEn);
	if (FAILED(hr)) return hr;
	
// ist Makro schon in Liste ?   pM -> AddRef()
	hr = pEn -> FindByName (strMacroName, &pM);		
	pEn -> Release();// kein passendes Objekt gefunden	        						
	if (FAILED(hr) || S_FALSE == GetScode(hr)) 	return hr;
	
	hr = SetData (pText, hCode, dwSaveFlag, pM);
//	 von FindByName()	
	pM -> Release();			           
// Commit() ?
	m_fNotCommit = true;
return hr;
}
Example #19
0
//***************************************************************************************
int CBCGPShellList::OnCompareItems (LPARAM lParam1, LPARAM lParam2, int iColumn)
{
	ASSERT_VALID (this);
	LPBCGCBITEMINFO pItem1 = (LPBCGCBITEMINFO)lParam1;
	LPBCGCBITEMINFO	pItem2 = (LPBCGCBITEMINFO)lParam2;
	ASSERT (pItem1 != NULL);
	ASSERT (pItem2 != NULL);

	SHFILEINFO	sfi1;
	SHFILEINFO	sfi2;

	TCHAR szPath1 [MAX_PATH];
	TCHAR szPath2 [MAX_PATH];

	CFileStatus fs1;
	CFileStatus fs2;

	int nRes = 0;

	switch (iColumn)
	{
	case BCGPShellList_ColumnName:
		{
			HRESULT hr = pItem1->pParentFolder->CompareIDs (0,
				pItem1->pidlRel,
				pItem2->pidlRel);
			
			if (FAILED (hr))
			{
				return 0;
			}
			
			nRes = (short) SCODE_CODE (GetScode (hr));
		}
		break;

	case BCGPShellList_ColumnType:
		if (SHGetFileInfo ((LPCTSTR)pItem1->pidlFQ, 0, &sfi1, sizeof(sfi1), SHGFI_PIDL | SHGFI_TYPENAME) &&
			SHGetFileInfo ((LPCTSTR)pItem2->pidlFQ, 0, &sfi2, sizeof(sfi2), SHGFI_PIDL | SHGFI_TYPENAME))
		{
			nRes = lstrcmpi (sfi1.szTypeName, sfi2.szTypeName);
		}
		break;

	case BCGPShellList_ColumnSize:
	case BCGPShellList_ColumnModified:
		if (SHGetPathFromIDList (pItem1->pidlFQ, szPath1) &&
			CFile::GetStatus (szPath1, fs1))
		{
			if (SHGetPathFromIDList (pItem2->pidlFQ, szPath2) &&
				CFile::GetStatus (szPath2, fs2))
			{
				if (iColumn == BCGPShellList_ColumnSize)
				{
					nRes =	fs1.m_size < fs2.m_size ? -1 : 
							fs1.m_size > fs2.m_size ? 1 : 0;
				}
				else
				{
					nRes =	fs1.m_mtime < fs2.m_mtime ? -1 : 
							fs1.m_mtime > fs2.m_mtime ? 1 : 0;
				}
			}
			else
			{
				nRes = 1;
			}
		}
		else
		{
			nRes = -1;
		}
		break;
	}

	return nRes;
}
Example #20
0
///////////////////////////////////////////////////////////////////////////////
// lokal verwendete Funktionen 
inline bool IMPL_AND_FAILED (HRESULT hr)
{
	return (FAILED(hr) && !(E_NOTIMPL == GetScode(hr)));
}
Example #21
0
int DriveBox_Fill(HWND hwnd)
{

  LPSHELLFOLDER lpsfDesktop;
  LPSHELLFOLDER lpsf; // Workspace == CSIDL_DRIVES

  LPITEMIDLIST  pidl;
  LPITEMIDLIST  pidlEntry;

  LPENUMIDLIST  lpe;

  COMBOBOXEXITEM  cbei;
  LPDC_ITEMDATA   lpdcid;

  ULONG dwAttributes = 0;

  DWORD grfFlags = SHCONTF_FOLDERS;


  // Init ComboBox
  SendMessage(hwnd,WM_SETREDRAW,0,0);
  SendMessage(hwnd,CB_RESETCONTENT,0,0);

  ZeroMemory(&cbei,sizeof(COMBOBOXEXITEM));
  cbei.mask = CBEIF_TEXT | CBEIF_IMAGE | CBEIF_SELECTEDIMAGE | CBEIF_LPARAM;
  cbei.pszText = LPSTR_TEXTCALLBACK;
  cbei.cchTextMax = MAX_PATH;
  cbei.iImage = I_IMAGECALLBACK;
  cbei.iSelectedImage = I_IMAGECALLBACK;


  // Get pidl to [My Computer]
  if (NOERROR == SHGetSpecialFolderLocation(hwnd,
                                            CSIDL_DRIVES,
                                            &pidl))
  {

    // Get Desktop Folder
    if (NOERROR == SHGetDesktopFolder(&lpsfDesktop))
    {

      // Bind pidl to IShellFolder
      if (NOERROR == lpsfDesktop->lpVtbl->BindToObject(
                                            lpsfDesktop,
                                            pidl,
                                            NULL,
                                            &IID_IShellFolder,
                                            &lpsf))

      {

        // Create an Enumeration object for lpsf
        if (NOERROR == lpsf->lpVtbl->EnumObjects(
                                        lpsf,
                                        hwnd,
                                        grfFlags,
                                        &lpe))

        {

          // Enumerate the contents of [My Computer]
          while (NOERROR == lpe->lpVtbl->Next(
                                            lpe,
                                            1,
                                            &pidlEntry,
                                            NULL))

          {

            // Add item to the List if it is part of the
            // Filesystem
            dwAttributes = SFGAO_FILESYSTEM;

            lpsf->lpVtbl->GetAttributesOf(
                            lpsf,
                            1,
                            &pidlEntry,
                            &dwAttributes);

            if (dwAttributes & SFGAO_FILESYSTEM)
            {

              // Windows XP: check if pidlEntry is a drive
              SHDESCRIPTIONID di;
              HRESULT hr;
              hr = SHGetDataFromIDList(lpsf,pidlEntry,SHGDFIL_DESCRIPTIONID,
                                        &di,sizeof(SHDESCRIPTIONID));
              if (hr != NOERROR || (di.dwDescriptionId >= SHDID_COMPUTER_DRIVE35 &&
                                    di.dwDescriptionId <= SHDID_COMPUTER_OTHER))
              {

                lpdcid = CoTaskMemAlloc(sizeof(DC_ITEMDATA));

                //lpdcid->pidl = IL_Copy(pidlEntry);
                lpdcid->pidl = pidlEntry;
                lpdcid->lpsf = lpsf;

                lpsf->lpVtbl->AddRef(lpsf);

                // Insert sorted ...
                {
                  COMBOBOXEXITEM cbei2;
                  LPDC_ITEMDATA lpdcid2;
                  HRESULT hr;
                  cbei2.mask = CBEIF_LPARAM;
                  cbei2.iItem = 0;

                  while ((SendMessage(hwnd,CBEM_GETITEM,0,(LPARAM)&cbei2)))
                  {
                    lpdcid2 = (LPDC_ITEMDATA)cbei2.lParam;
                    hr = (lpdcid->lpsf->lpVtbl->CompareIDs(
                                lpdcid->lpsf,
                                0,
                                lpdcid->pidl,
                                lpdcid2->pidl));

                    if ((short)(SCODE_CODE(GetScode(hr))) < 0)
                      break;
                    else
                      cbei2.iItem++;
                  }

                  cbei.iItem = cbei2.iItem;
                  cbei.lParam = (LPARAM)lpdcid;
                  SendMessage(hwnd,CBEM_INSERTITEM,0,(LPARAM)&cbei);

                }

              }

            }

          } // IEnumIDList::Next()

          lpe->lpVtbl->Release(lpe);

        } // IShellFolder::EnumObjects()

        lpsf->lpVtbl->Release(lpsf);

      } // IShellFolder::BindToObject()

      CoTaskMemFree(pidl);

    } // SHGetSpecialFolderLocation()

    lpsfDesktop->lpVtbl->Release(lpsfDesktop);

  } // SHGetDesktopFolder()


  SendMessage(hwnd,WM_SETREDRAW,1,0);
  // Return number of items added to combo box
  return ((int)SendMessage(hwnd,CB_GETCOUNT,0,0));

}
Example #22
0
// handy function to display Automation errors
void ShowException (LPOLESTR szMember, HRESULT hr, EXCEPINFO *pexcep, unsigned int uiArgErr)
{
	char *str;
	char memstr[STRSIZE+1], mes[STRSIZE+1];

	memstr[STRSIZE] = '\0';
	mes[STRSIZE]    = '\0';

	strncpyfar(memstr, szMember, STRSIZE);
	
	switch (GetScode(hr)) 
	{
		case DISP_E_UNKNOWNNAME:
			sprintf(mes, "%s: Unknown name or named argument.", memstr);
			break;
	
		case DISP_E_BADPARAMCOUNT:
			sprintf(mes, "%s: Incorrect number of arguments.", memstr);
			break;
			
		case DISP_E_EXCEPTION:
			sprintf(mes, "%s: Error %d: ", memstr, pexcep->wCode);
			if (pexcep->bstrDescription != NULL) 
			{
				str = BstrToCstr(pexcep->bstrDescription);
				strcat(mes, str);
				free(str);
			}
			else 
			{
				strcat(mes, "<<No Description>>");
			}
			break;
			
		case DISP_E_MEMBERNOTFOUND:
			sprintf(mes, "%s: method or property not found.", memstr);
			break;
		
		case DISP_E_OVERFLOW:
			sprintf(mes, "%s: Overflow while coercing argument values.", memstr);
			break;
		
		case DISP_E_NONAMEDARGS:
			sprintf(mes, "%s: Object implementation does not support named arguments.",
						memstr);
		    break;
		    
		case DISP_E_UNKNOWNLCID:
			sprintf(mes, "%s: The locale ID is unknown.", memstr);
			break;
		
		case DISP_E_PARAMNOTOPTIONAL:
			sprintf(mes, "%s: Missing a required parameter.", memstr);
			break;
		
		case DISP_E_PARAMNOTFOUND:
			sprintf(mes, "%s: Argument not found, argument %d.", memstr, uiArgErr);
			break;
			
		case DISP_E_TYPEMISMATCH:
			sprintf(mes, "%s: Type mismatch, argument %d.", memstr, uiArgErr);
			break;

		default:
			sprintf(mes, "%s: Unknown error occured.", memstr);
			break;
	}
	
	printf(mes);
}
Example #23
0
void tOleHandler::SizeSet(LPSIZEL pszl, BOOL fDevice, BOOL fInformObj)
    {
    SIZEL           szl;

    if (!fDevice)
        {
        szl=*pszl;
        m_rcl.right =pszl->cx+m_rcl.left;
        m_rcl.bottom=pszl->cy+m_rcl.top;
        }
    else
        {
        RECT        rc;

        SetRect(&rc, (int)pszl->cx, (int)pszl->cy, 0, 0);
        RectConvertMappings(&rc, NULL, FALSE);

        m_rcl.right =(long)rc.left+m_rcl.left;
        m_rcl.bottom=(long)rc.top+m_rcl.top;

        SETSIZEL(szl, (long)rc.left, (long)rc.top);
        }

    //Tell OLE that this object was resized.
    if (NULL!=m_pIOleObject && fInformObj)
        {
        HRESULT     hr;
        BOOL        fRun=FALSE;

        //Convert our LOMETRIC into HIMETRIC by *=10
        szl.cx*=10;
        szl.cy*=-10;    //Our size is stored negative.

        /*
         * If the MiscStatus bit of OLEMISC_RECOMPOSEONRESIZE
         * is set, then we need to run the object before calling
         * SetExtent to make sure it has a real chance to
         * re-render the object.  We have to update and close
         * the object as well after this happens.
         */

        if (OLEMISC_RECOMPOSEONRESIZE & m_grfMisc)
            {
            if (!OleIsRunning(m_pIOleObject))
                {
                OleRun(m_pIOleObject);
                fRun=TRUE;
                }
            }

        hr=m_pIOleObject->SetExtent(m_fe.dwAspect, &szl);

        /*
         * If the object is not running and it does not have
         * RECOMPOSEONRESIZE, then SetExtent fails.  Make
         * sure that we call SetExtent again (by just calling
         * SizeSet here again) when we next run the object.
         */
        if (SUCCEEDED(hr))
            {
            m_fSetExtent=FALSE;

            if (fRun)
                {
                m_pIOleObject->Update();
                m_pIOleObject->Close(OLECLOSE_SAVEIFDIRTY);
                }
            }
        else
            {
            if (OLE_E_NOTRUNNING==GetScode(hr))
                m_fSetExtent=TRUE;
            }
        }

    return;
    }
Example #24
0
// Öffnen des PropertySequenceSubStorages
static HRESULT GetSubPropSeqStorage (IStorage **ppIStg, bool fCreate = false)
{
	if (NULL == ppIStg) return E_POINTER;

WStorage IRootStg;

	if (!DEX_GetProjectStorage(*IRootStg.ppv()))
		return E_FAIL;

	USES_CONVERSION;

WStorage IStg;
HRESULT hr = E_FAIL;

	{
	bool fRO = false;

		hr = IRootStg -> OpenStorage (A2OLE(g_cbPropertySequences), NULL, 
							STGM_READWRITE|STGM_SHARE_EXCLUSIVE|STGM_TRANSACTED, 
							NULL, 0L, IStg.ppi());
		if (FAILED(hr)) {
			if (STG_E_FILENOTFOUND == GetScode(hr) && fCreate) {
			// existiert nicht, evtl. neu erzeugen
				hr = IRootStg -> CreateStorage (A2OLE(g_cbPropertySequences), 
									STGM_READWRITE|STGM_SHARE_EXCLUSIVE|STGM_TRANSACTED|STGM_CREATE, 
									0L, 0L, IStg.ppi());
				if (SUCCEEDED(hr))
					hr = WriteClassStg (IStg, CLSID_PropertyActionSequence);
			
			} else if (STG_E_ACCESSDENIED == GetScode(hr)) {
			// mit Schreibschutz versuchen
				hr = IRootStg -> OpenStorage (A2OLE(g_cbPropertySequences), NULL, 
								STGM_READ|STGM_SHARE_EXCLUSIVE|STGM_TRANSACTED, 
								NULL, 0L, IStg.ppi());
				fRO = true;
			
			} else
				return hr;
		} 

		if (SUCCEEDED(hr)) {
		CLSID clsId;

			hr = ReadClassStg (IStg, &clsId);
			if (FAILED(hr)) return hr;

			if (!IsEqualCLSID(clsId, CLSID_PropertyActionSequence) && 
				!IsEqualCLSID(clsId, CLSID_NULL))
			{
				return E_FAIL;
			}

			if (IsEqualCLSID(clsId, CLSID_NULL) && !fRO)
				hr = WriteClassStg (IStg, CLSID_PropertyActionSequence);
		}
	}

	if (FAILED(hr)) return hr;

	*ppIStg = IStg.detach();

return hr;
}
Example #25
0
static void
ShowException(const wxString& member,
              HRESULT hr,
              EXCEPINFO *pexcep,
              unsigned int uiArgErr)
{
    wxString message;
    switch (GetScode(hr))
    {
        case DISP_E_UNKNOWNNAME:
            message = _("Unknown name or named argument.");
            break;

        case DISP_E_BADPARAMCOUNT:
            message = _("Incorrect number of arguments.");
            break;

        case DISP_E_EXCEPTION:
            if ( pexcep )
            {
                if ( pexcep->bstrDescription )
                    message << pexcep->bstrDescription << wxS(" ");
                message += wxString::Format(wxS("error code %u"), pexcep->wCode);
            }
            else
            {
                message = _("Unknown exception");
            }
            break;

        case DISP_E_MEMBERNOTFOUND:
            message = _("Method or property not found.");
            break;

        case DISP_E_OVERFLOW:
            message = _("Overflow while coercing argument values.");
            break;

        case DISP_E_NONAMEDARGS:
            message = _("Object implementation does not support named arguments.");
            break;

        case DISP_E_UNKNOWNLCID:
            message = _("The locale ID is unknown.");
            break;

        case DISP_E_PARAMNOTOPTIONAL:
            message = _("Missing a required parameter.");
            break;

        case DISP_E_PARAMNOTFOUND:
            message.Printf(_("Argument %u not found."), uiArgErr);
            break;

        case DISP_E_TYPEMISMATCH:
            message.Printf(_("Type mismatch in argument %u."), uiArgErr);
            break;

        case ERROR_FILE_NOT_FOUND:
            message = _("The system cannot find the file specified.");
            break;

        case REGDB_E_CLASSNOTREG:
            message = _("Class not registered.");
            break;

        default:
            message.Printf(_("Unknown error %08x"), hr);
            break;
    }

    wxLogError(_("OLE Automation error in %s: %s"), member, message);
}
Example #26
0
STDMETHODIMP CIMacroScriptImp :: GetScript (LPCSTR pcName, LPSTR *ppcMacroText,
											ebHCODE *phCode)
{                        
	ASSERT(pcName);

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

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

	*ppcMacroText = NULL;

	if (S_FALSE == GetScode(hr)) {

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

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

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

		return ResultFromScode (S_FALSE);
	
	} else {

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

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