Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Set a file's properties

Status
Not open for further replies.

comaboy

Programmer
Nov 6, 2001
261
GB
Ok, so I've generated an .rtf file. What I need to do now is set some document Summary Properties (ie Title, Author, etc). I've tried playing with DSOFILE with no luck, and I'm sure there MUST be an API call to do this... I can't find it anywhere. Can anyone point me in the right direction?

TIA !
 
I could be wrong, but if you read the docs on DSOFILE I think you'll find that you can (should?) only set these properties for MS documents like Work or Excel. I remember trying this a while ago and getting nowhere with it. DSOFILE kept throwing errors...
 
DSOFile allows you to read and edit builtin and custom properties of already extant structured storage Office files; it cannot be used to add structured storage features to files that are not already.

Once upon a time Microsoft shipped a support library known as OfficeCompatible 1.0 (msoc.dll) with Office which, amongst other things, allowed you to create your own structured storage Office compatible documents. Sadly this is a) no longer shipped with Office and b) no longer seems to be available for download (and to be fair, there's no guarantee it would work with current versions of Office, since it was designed for Office 97)
 
Strongm,

Good point about Structured Strorage, however, I hex'd my test files with no luck, so I'm not sure if the data is stored Structured or as a Stream. Being that this should only work on NTFS, I would guess (actually 99% sure) that the info is in some kind of "filename.rtf:meta" stream.

Keith,

Depends on which version - 2.0 is a totally different beast! - But I'd still like to find the API as I hate installing .dll's all over the place! ;-)

All,

I've done a little experimentation, here's what I've come up with...

1. I can set the Title, Subject, etc properties via the Menu commands in Winword2003 (as .rtf) and save fine - shows up in explorer no problem. The same operation when automated from VB6 fails silently, whether the file is an .rtf or .doc

2. Using the shell (under NTFS), you can (again) manually set the properties (but I can't find the api for love nor money).

Now this has to be do-able! And lets face it, it would make a blinding FAQ because it would be so handy to be able automatically create "proper" document libraries that are fully searchable simply though Windows.

TIA again,

Comaboy
 
>actually 99% sure

Compound documents don't use NTFS streams. If they did, then they wouldn't have worked on Windows for Workgroups, Windows 95, Windows 98, or Windows Me

>but I can't find the api for love nor money

It isn't an API - the shell uses registered property page handlers (as a result I'm not aware of any straighforward shell interfaces that allow you to create or modify 'custom' attributes for a file, although reading such values is fairly straightforward through GetExtended)

What you need is access to IPropertyStorage and IPropertySetStorage - only neither of them are VB friendly, so you need to find an apprpriate type library ...


 
Strongm,

I'll defer to your superior knowledge on this one. However You're reply does raise an issue I can't get my head round.

If you create a small text file on your desktop, you can Right-Click, choose Properties and using the Summary tab set the Title, Author, etc.

Now a plain .txt (I always beleived) is just that - not "Structured" in any way - so if not in a Stream, where are these properties actually stored? Does Windows silently turn it into a Compound file in the background? [surprise]

I'll do some research into IPropertyStorage and IPropertySetStorage (and probably dissapear into a mire of confusion!)

Thanks again Strongm,

Comaboy
 
Well, yes, under NTFS 5.0, there is an implementation of structured storage which happens to nbe implemented in an alternate NTFS stream for documents that are not already compound documents. However, you still need IPropertySetStorage and IPropertyStorage (and there are then some additional limitations on these interfaces)

Here are some notes from Microsoft:
 
OMG! Talk about "many a word said in jest" ! [surprise]

So, to recap: The data is stored in separate Stream... but encapsulated as OSS data. Nice! At this point I should say that I have, to be honest, only a small amount of knowledge of MS Structured Storage. Now that the light has dawned, I realise that this post should have been placed be in a "Data Storage" forum.

Thanks for the pointers to the IProperty...'s Strongm, I'll investigate, but being that this isn't the open and shut case I first thought it was, (and I've only got two files to set the properties for) it may take a while. If I manage to crack it, I'll post an FAQ.

Yet again thanks, Strongm.
 
I am looking for a similar already-built utility and wondering if were you ever successful in implementing this? Any assistance would be most appreciated.
 
Desaware have a structured storage control called StorageTools that should do the trick. Have to admit I've not used it, though - and I think you can only get it as part of their full toolset nowadays
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top