File Properties and C++ Beginner

 

Hello,

I'm new in this Forum and also not very familiar with C++ programming. I want to write a code that reads the custom file properties with using the StructuredStorage API.

Can anyone of  you give me please an example how to do that. I don't know how to implement the API and how to read the properties. 

I found an old thread, but not the example. http://www.jasonnewell.net/Forums/tabid/55/forumid/1/postid/878/view/topic/Default.aspx

Thank you for your help in advance.

Andi   

 

Posted by: Andreas Wuerth
Post date: 12/17/2007 9:07:12 PM

3 REPLIES

RE: File Properties and C++ Beginner

 

Hi Andi,

Look here. There is also the .Net 2.0 version attached to the last post.

Cheers

Calum

 

Posted by: Calum McLellan
Post date: 12/18/2007 8:06:11 AM

RE: File Properties and C++ Beginner

Hello,

 

I still try to work with the StructuredStorage and VC6 and unfortunately I don't have enough experience to get it working.

I know a bit VBS and would like to ask someone of you to translate following code into C++.

 

Set objProps = CreateObject("StructuredStorage.PropertySets")

call objProps.Open("c:\TestFile.par", true)

Value = objProps.Item("Custom").Item("Density").value

MsgBox "Density: " & Value

 

Thanks in advance

 

Andi

 

 

Posted by: Andreas Wuerth
Post date: 1/9/2008 8:17:41 AM

RE: File Properties and C++ Beginner

 

Hi Andi,

if you've installed my StructuredStorage library (Version 6.0) then the source code is in the installation folder. This will show you pretty much all you'll need for basic file property manipulation directly using the win API. The code does not yet include the fixes mentioned in the posts (unicode problem with office files and the error with boolean values - although I'm pretty sure the boolean thing was a .net interop problem and won't show up in the c++ version).

If you just want to use the library then here's an example. You will need a new C++ project with ATL support and you'll have to add the structured storage installation folder to the include directories in the project properties. I would have just made a demo project but I don't have VC6

Hope this helps. Here's the code:

HEADER FILE:// stdafx.h : include file for standard system include files,// or project specific include files that are used frequently, but// are changed infrequently//#pragma once#ifndef _WIN32_WINNT // Allow use of features specific to Windows XP or later. #define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows.#endif #include stdio.h>#include tchar.h>#include atlbase.h>#include atlcom.h>#include atlsafe.h>#import "StructuredStorage.tlb" raw_interfaces_only

CODE FILE:// StructuredStorageTest.cpp : Defines the entry point for the console application.//#include "stdafx.h"int _tmain(int argc, _TCHAR* argv[]){ CoInitialize(NULL); CLSID clsid; HRESULT hr = CLSIDFromProgID(L"StructuredStorage.PropertySets", &clsid); if (SUCCEEDED(hr)) { :Smiley FrustratedtructuredStorage::IPropertySets* propSets = NULL; hr = CoCreateInstance(clsid, NULL, CLSCTX_SERVER, IID_IDispatch, (void**) &propSets); if (SUCCEEDED(hr)) { hr = propSets->Open(_bstr_t(L"C:\\Temp.par"), false); if (SUCCEEDED(hr)) { :Smiley FrustratedtructuredStorage::IPropertySet* propSet = NULL; hr = propSets->get_Item(_variant_t(L"Custom"), &propSet); if (SUCCEEDED(hr)) { :Smiley FrustratedtructuredStorage::IProperty* prop = NULL; hr = propSet->get_Item(_variant_t(L"Test"), ∝); if (SUCCEEDED(hr)) { _variant_t value; hr = prop->get_Value(&value); if (SUCCEEDED(hr)) MessageBox(NULL, value.bstrVal, L"Test", NULL); prop->Release(); } propSet->Release(); } } propSets->Release(); } } return 0;}

 

Posted by: Calum McLellan
Post date: 1/9/2008 9:05:42 AM