Click here to Skip to main content
15,888,351 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionDrawing a bitmap on DC created by BYTE* array Pin
TalSt18-May-08 3:29
TalSt18-May-08 3:29 
AnswerRe: Drawing a bitmap on DC created by BYTE* array [modified] Pin
Baltoro18-May-08 12:20
Baltoro18-May-08 12:20 
AnswerRe: Drawing a bitmap on DC created by BYTE* array Pin
Dan18-May-08 13:31
Dan18-May-08 13:31 
AnswerRe: Drawing a bitmap on DC created by BYTE* array Pin
TalSt18-May-08 19:27
TalSt18-May-08 19:27 
Questionfile accessing problem Pin
Chandrasekharan P18-May-08 3:26
Chandrasekharan P18-May-08 3:26 
AnswerRe: file accessing problem Pin
Nelek18-May-08 7:15
protectorNelek18-May-08 7:15 
AnswerRe: file accessing problem Pin
chandu00418-May-08 19:53
chandu00418-May-08 19:53 
QuestionReading Non-Ole File Property Pin
tprakash18-May-08 3:00
tprakash18-May-08 3:00 
We are trying to read Non-Ole File Properties (eg office 2007) using dsofile.dll. We can easily read properties of both Ole(doc file 97,2003) and non-ole(office 2007) using dsofile.dll(com dll). We did not use dsofile com dll because it has to be registered and take reference in the calling C# project. Actually we re-wrote our own dll using visual c++.net. The main interface for reading ole file property is IStoragePropertySet object. Here is the code snippets

// If the file is an OLE Storage DocFile...
if(StgIsStorageFile(m_bstrFileName)==S_OK)
{
IStorage *pStorage = NULL;
IPropertySetStorage *pPropSetStg = NULL;
HRESULT hr;

// Open the document as an OLE compound document.
hr = ::StgOpenStorage(wcFilename, NULL,
STGM_READ | STGM_SHARE_EXCLUSIVE, NULL, 0, &pStorage);
}
else
{
//How to get non-ole file properties
}

As I showed the code snippets, there is no problem in getting ole-file properties. What we are struck in is getting non-ole file property.

Here is the code snippets from the original source code of dsofile com dll.

// If the file is an OLE Storage DocFile...
    if (StgIsStorageFile(m_bstrFileName) == S_OK)
    {
     // Get the data from IStorage...
	    hr = StgOpenStorage(m_bstrFileName, NULL, dwOpenMode, NULL, 0, &m_pStorage);

     // If we failed to gain write access, try to just read access if caller allows
	 // it. This function will open the OLE file in transacted read mode, which
	 // covers cases where the file is in use or is on a read-only share. We can't
	 // save after the open so we force the read-only flag on...
        if (((hr == STG_E_ACCESSDENIED) || (hr == STG_E_SHAREVIOLATION)) && 
            (m_dwFlags & dsoOptionOpenReadOnlyIfNoWriteAccess))
        {
            m_fReadOnly = TRUE;
	        hr = StgOpenStorage(m_bstrFileName, NULL, 
				(STGM_READ | STGM_TRANSACTED | STGM_SHARE_DENY_NONE), NULL, 0, &m_pStorage);
        }
        
	 // If we are lucky, we have a storage to read from, so ask OLE to open the 
	 // associated property set for the file and return the IPSS iface...
	    if (SUCCEEDED(hr))
        {
            hr = m_pStorage->QueryInterface(IID_IPropertySetStorage, (void**)&m_pPropSetStg);
        }
    }
    else if ((m_dwFlags & dsoOptionOnlyOpenOLEFiles) != dsoOptionOnlyOpenOLEFiles)
    {
	 // If caller would like non-OLE property sets, we can try to provide them. There
	 // are two types: (1) explicit metadata handlers registered by file type; or (2) 
	 // NTFS 5.0+ property stream data in NTFS file header (which is actually saved as
	 // alternate stream). The former is custom provider to save data inside the file 
	 // without using OLE. The later is available for any file on NTFS5 disk.
		CLSID clsidMetaHandler = {0};
		IPersistFile *prtsf = NULL;

		if (DsoGetMetaHandler(m_bstrFileName, &clsidMetaHandler) == S_OK)
		{
		 // Create instance of the Metadata Handler object...
			hr = CoCreateInstance(clsidMetaHandler, NULL, CLSCTX_INPROC, IID_IPersistFile, (void**)&prtsf);
			if (SUCCEEDED(hr))
			{
			 // Ask it to load the file for parsing...
				hr = prtsf->Load(m_bstrFileName, dwOpenMode);
				if (SUCCEEDED(hr))
				{
				 // If it succeeded, ask for the property set storage...
					hr = prtsf->QueryInterface(IID_IPropertySetStorage, (void**)&m_pPropSetStg);
					if (SUCCEEDED(hr)){ASSIGN_INTERFACE(m_pPrstFile, prtsf);}
				}
				prtsf->Release();	
			}
			else hr = DSO_E_NODOCUMENTPROPS; // bad news, unable to load handler.
		}
		else if (v_pfnStgOpenStorageEx)
		{
		 // On Win2K+ we can try and open plain files on NTFS 5.0 drive and get 
		 // the NTFS version of OLE properties (saved in alt stream)...
			hr = (v_pfnStgOpenStorageEx)(m_bstrFileName, dwOpenMode, STGFMT_FILE, 0, NULL, 0, 
					IID_IPropertySetStorage, (void**)&m_pPropSetStg);

		 // If we failed to gain write access, try to just read access if caller
		 // wants us to. This only works for access block, not share violations...
		   if ((hr == STG_E_ACCESSDENIED) && (!m_fReadOnly) && 
				(m_dwFlags & dsoOptionOpenReadOnlyIfNoWriteAccess))
			{
				m_fReadOnly = TRUE;
				hr = (v_pfnStgOpenStorageEx)(m_bstrFileName, (STGM_READ | STGM_SHARE_EXCLUSIVE), STGFMT_FILE,
					0, NULL, 0, IID_IPropertySetStorage, (void**)&m_pPropSetStg);
			}
		}


We successfully converted the code in italic ie for ole file. We are trying to convert code in bold ie for non-ole but we are not yet success. What we are trying to do is
to read the non-ole file properties using dll instead of com dll(ie dsofile.dll).

We are very much eager to hear you genius guys.



Thank You

Prakash Tandukar
AnswerRe: Reading Non-Ole File Property Pin
thonti29-May-08 23:41
thonti29-May-08 23:41 
AnswerRe: Reading Non-Ole File Property Pin
thonti9-Jun-08 3:50
thonti9-Jun-08 3:50 
Questioninvalid number of parameters in ActiveX Pin
samira forooghi18-May-08 0:37
samira forooghi18-May-08 0:37 
AnswerRe: invalid number of parameters in ActiveX Pin
Nelek18-May-08 0:39
protectorNelek18-May-08 0:39 
GeneralRe: invalid number of parameters in ActiveX Pin
samira forooghi19-May-08 1:55
samira forooghi19-May-08 1:55 
AnswerRe: invalid number of parameters in ActiveX Pin
prasad_som18-May-08 1:04
prasad_som18-May-08 1:04 
QuestionGetControlUnknown Pin
subramanyeswari18-May-08 0:08
subramanyeswari18-May-08 0:08 
AnswerRe: GetControlUnknown Pin
JudyL_MD18-May-08 12:39
JudyL_MD18-May-08 12:39 
QuestionDraw on desktop Pin
capint17-May-08 23:06
capint17-May-08 23:06 
AnswerRe: Draw on desktop [modified] Pin
Nelek17-May-08 23:47
protectorNelek17-May-08 23:47 
GeneralRe: Draw on desktop Pin
capint18-May-08 2:07
capint18-May-08 2:07 
GeneralRe: Draw on desktop Pin
Nelek18-May-08 7:04
protectorNelek18-May-08 7:04 
QuestionSave data into a DataBase Pin
cuesdean florin17-May-08 21:46
cuesdean florin17-May-08 21:46 
AnswerRe: Save data into a DataBase Pin
David Crow19-May-08 4:45
David Crow19-May-08 4:45 
QuestionC# SendMessage in C++ Pin
luisgrimaldo17-May-08 17:59
luisgrimaldo17-May-08 17:59 
AnswerRe: C# SendMessage in C++ Pin
Hamid_RT17-May-08 19:12
Hamid_RT17-May-08 19:12 
QuestionNeed XML Alternative for Persisting Object Data Pin
Peter Weyzen17-May-08 16:28
Peter Weyzen17-May-08 16:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.