Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
T

thonti

@thonti
About
Posts
2
Topics
0
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Reading Non-Ole File Property
    T thonti

    For reading Non ole files(office 2007 files) if (NonOLEGetMetaHandler(m_bstrFileName, &clsidMetaHandler) == S_OK) { CoInitialize(NULL); // 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, (STGM_READWRITE | STGM_SHARE_EXCLUSIVE)); 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); // hr= m_pPropSetStg->Create(FMTID_SummaryInformation, // 0, // PROPSETFLAG_DEFAULT, // STGM_READWRITE | STGM_SHARE_EXCLUSIVE,&m_pSummaryInfoStg); hr = SetSummaryInfoStorage(); if(FAILED(hr)) { printf(" Summaryinfo storage failed w/error %08lx", hr); return hr; } hr = SetCustomInfoStorage(); if(FAILED(hr)) { printf(" Custom storage failed w/error %08lx", hr); return hr; } prtsf->Release(); } } HRESULT CFileProperties::NonOLEGetMetaHandler(LPCWSTR pwszFile, LPCLSID lpClsid) { HRESULT hret = REGDB_E_CLASSNOTREG; // Assume no handler HKEY hkeyExt, hkeyHandler = NULL; LPSTR pszExt; if ((pwszFile == NULL) || (*pwszFile == L'\0') || (lpClsid == NULL)) return E_INVALIDARG; // Get the extension for the file... pszExt = NonOLEConvertToMBCS(GetExtensionPart(pwszFile), CP_ACP); if (pszExt == NULL) return E_OUTOFMEMORY; // Now get the key that is associated with that extension... hkeyExt = GetHKCRKey("%s", pszExt); if (hkeyExt) { // Check for the handler under that ke

    C / C++ / MFC csharp c++ com help tutorial

  • Reading Non-Ole File Property
    T thonti

    for non- ole file types we have to get pointer of IID_IPropertySetStorage rather than istorage and the rest will be the same. only problme here is we cant update office 2007 file type as the file structure of office 2007 file type is bit different. if you fine any solution for accessing office 2007 do let me know. if(nFileType == non- ole) { hr =SetPropertySetStorage(pszFilePath); if (hr == S_OK ) { hr = SetSummaryInfoStorage(); if(FAILED(hr)) { printf(" Summaryinfo storage failed w/error %08lx", hr); return hr; } hr = SetCustomInfoStorage(); if(FAILED(hr)) { printf(" Custom storage failed w/error %08lx", hr); return hr; } } else { return hr; } } HRESULT CFileProperties::SetPropertySetStorage(const char * pszFilePath ) { HRESULT hr = S_OK; if(pszFilePath == NULL && m_pStorage != NULL) { hr = m_pStorage->QueryInterface(IID_IPropertySetStorage, (void **)&m_pPropSetStg); if(FAILED(hr)) { printf("QI for IPropertySetStorage failed w/error %08lx", hr); //Releasing IStorage m_pStorage->Release(); m_pStorage = NULL; return hr; } } else if(pszFilePath != NULL && m_pStorage == NULL) { // Translate filename to Unicode. WCHAR wcFilename[1024]; setlocale( LC_ALL, "" ); int i = mbstowcs(wcFilename, pszFilePath , strlen(pszFilePath )); setlocale( LC_ALL, "C" ); wcFilename[i] = 0; // Open the document as an OLE compound document. hr = StgOpenStorageEx( wcFilename, STGM_READ|STGM_SHARE_DENY_WRITE, STGFMT_ANY, 0, NULL, NULL, IID_IPropertySetStorage, reinterpret_cast<void**>(&m_pPropSetStg) ); if(FAILED(hr)) { if(hr == STG_E_FILENOTFOUND) printf("File not found."); else if(hr == STG_E_FILEALREADYEXISTS) printf("Not a compound file."); else pr

    C / C++ / MFC csharp c++ com help tutorial
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups