I have been getting the error when the file does not have any Summary
fields set in the first place. If I go into the file's property Summary
tab and set a comment in the Comments and then try to set a
SummaryProperties property, it worked without error.
The problem seems to come from the dsofile.dll in the
CDsoSummaryProperties::GetPropertyFromList which is called from
CDsoSummaryProperties::WriteProperty method. When there are no
properties (or pitem) in the file's (ADS) SummaryInformation,
dsofile.dll doesn't seem to make a new item.
Solution: Email me for a debug build of the dsofile.dll file or get the
package which has the source from
http://support.microsoft.com/?id=224351 and change the
CDsoSummaryProperties::GetPropertyFromList to look something like
below.
Use at your own risk. (No warranties, no obligations, no liability, and
that other legal stuff.) I haven't tested it thoroughly since it has
been doing what I've been trying to do.
summprops.cpp - about line 733
////////////////////////////////////////////////////////////////////////
// GetPropertyFromList -- Enumerates a list and finds item with the
// matching id. It can also add a new item (if flag set).
//
STDMETHODIMP_(CDsoDocProperty*)
CDsoSummaryProperties::GetPropertyFromList(CDsoDocProperty* plist,
PROPID id, BOOL fAppendNew)
{
CDsoDocProperty* pitem = plist;
CDsoDocProperty* plast = pitem;
ODS("CDsoSummaryProperties::FindPropertyInList\n");
// Loop the list until you find the item...
while (pitem)
{
if (pitem->GetID() == id)
break;
plast = pitem;
pitem = pitem->GetNextProperty();
}
// If no match is found, we can add a new item to end of the list...
if ((pitem == NULL)
// && (plast)
&& (fAppendNew))
{
// Create the item...
pitem = new CDsoDocProperty();
if (pitem)
{
VARIANT var; var.vt = VT_EMPTY;
if (FAILED(pitem->InitProperty(NULL, id, &var, TRUE, plast
== NULL ? NULL : (plast->AppendLink(pitem)) )))
{ // If we fail, try to reverse the append and kill the new
object...
if (plast == NULL)
{
}
else
{
plast->AppendLink((pitem->GetNextProperty()));
}
pitem->Release();
pitem = NULL;
}
}
}
return pitem;
}
Cheers,
Randy
--
snorter88
------------------------------------------------------------------------
Posted via http://www.codecomments.com
------------------------------------------------------------------------
>
>..... And another question you may be able to help with. Using
>DSOfile.dll to insert a custom property into say, test.txt. The
>property appears to insert OK, I can see it using the VB7 demo app and
>in the Properties tab. I open, change and close test.txt from the
>desktop ... and no more custom property. Looks like Notepad or the
>Windows OS has politely removed it. What gives ?
Almost everybody in this newsgroup is using VB6 or lower.
While you may get a stray answer to VB.NET (including VB2003
and VB2005 which has dropped .NET from its name) questions here,
you should ask them in newsgroups devoted exclusively to
.NET programming.
You risk getting confusing and/or misleading replies.
Look for newsgroups with either the word "dotnet" or "vsnet" in
their name.
For the microsoft news server, try these newsgroups...
news://msnews.microsoft.com/microsoft.public.dotnet.general
news://msnews.microsoft.com/microsoft.public.dotnet.languages.vb
news://msnews.microsoft.com/microsoft.public.vsnet.general
news://msnews.microsoft.com/microsoft.public.vstudio.general
news://msnews.microsoft.com/microsoft.public.vstudio.setup
news://msnews.microsoft.public.dotnet.languages.vb.upgrade
news://msnews.microsoft.public.dotnet.languages.vb.controls
news://msnews.microsoft.public.dotnet.languages.vb.data
There are some others, but these should get you started.
Thank you very much for the source code correction !!!
I could't update the "title" and "category" fields if they were not
manually set before. Now it works perfectly, even with PDF files.
--
Emeric
You can get it here: 'dsofile.dll'
(http://briefcase.yahoo.com/bc/kcrichar/lst?.dir=/My+Shares)
--
kcrichar