G
Gorgoroth
I have been using the DSOFile.dll for some time now to extract and modify
extended document properties. Lately however I noticed a problem: Whenever I
tried to write to a Property of a file that had no properties yet (a file
that my application had just created from a bytestream in this case), I would
get an Access Violation error.
With real OLE files (office documents mostly) this wasn't a problem, since
those always seem to have at least one property, however my current project
requires extended properties to be available in textfiles and other formats
as well.
If I used the Windows property-window to modify an extended property
(author, title, etc.), saved the changes and then ran my program everything
worked fine, this seemed to indicate that what I tried to do should in fact
be possible, using DSOFile however, it wasn't.
Luckily the dsofile installer provides you with the DLLs sourcecode, so I
was able to look through there and see if I found any obvious reasons for the
strange behavior.
When you open up the project and take a look at
CDsoSummaryProperties::GetPropertyFromList and
CDsoCustomProperties::GetPropertyFromList you will notice there is a
difference between these functions in the way they handle adding new items to
the list.
SummaryProperties (the one that didn't work for me) only allows adding new
items to the list if there is a previous item that can be linked to,
otherwise it would throw an E_ACCESSDENIED, exactly the error I was seeing.
I altered the sourcecode to simply pass NULL if no previous item existed,
however I was unsure if there was a reason for this limitation.
After compiling and including the new DSOFile.dll, my software seemed to
work fine, the problem was gone.
Now I wanted to head back and alter the CustomProperties GetPropertyFromList
as well, however on opening the file I noticed that that function already
does what I did as well, it checks wether a predecessor exists, otherwise it
passes NULL.
After some more testing it still appears that my changes are valid, the code
works as intended and no new errors have shown up, I'm still a little baffled
though. Why would CustomProperties include the (apperantly) right way of
adding a first item to a list, while SummaryProperties (in the same project)
did not?
Does anyone know if this behavior was intended and if my change will cause
further problems down the road that I'm not seeing at the moment? I don't
want to release a potentially dangerous, modified version of a Microsoft DLL
to my customers, however right now it seems to be the most feasible solution.
Sincerely,
Kevin Wienhold
extended document properties. Lately however I noticed a problem: Whenever I
tried to write to a Property of a file that had no properties yet (a file
that my application had just created from a bytestream in this case), I would
get an Access Violation error.
With real OLE files (office documents mostly) this wasn't a problem, since
those always seem to have at least one property, however my current project
requires extended properties to be available in textfiles and other formats
as well.
If I used the Windows property-window to modify an extended property
(author, title, etc.), saved the changes and then ran my program everything
worked fine, this seemed to indicate that what I tried to do should in fact
be possible, using DSOFile however, it wasn't.
Luckily the dsofile installer provides you with the DLLs sourcecode, so I
was able to look through there and see if I found any obvious reasons for the
strange behavior.
When you open up the project and take a look at
CDsoSummaryProperties::GetPropertyFromList and
CDsoCustomProperties::GetPropertyFromList you will notice there is a
difference between these functions in the way they handle adding new items to
the list.
SummaryProperties (the one that didn't work for me) only allows adding new
items to the list if there is a previous item that can be linked to,
otherwise it would throw an E_ACCESSDENIED, exactly the error I was seeing.
I altered the sourcecode to simply pass NULL if no previous item existed,
however I was unsure if there was a reason for this limitation.
After compiling and including the new DSOFile.dll, my software seemed to
work fine, the problem was gone.
Now I wanted to head back and alter the CustomProperties GetPropertyFromList
as well, however on opening the file I noticed that that function already
does what I did as well, it checks wether a predecessor exists, otherwise it
passes NULL.
After some more testing it still appears that my changes are valid, the code
works as intended and no new errors have shown up, I'm still a little baffled
though. Why would CustomProperties include the (apperantly) right way of
adding a first item to a list, while SummaryProperties (in the same project)
did not?
Does anyone know if this behavior was intended and if my change will cause
further problems down the road that I'm not seeing at the moment? I don't
want to release a potentially dangerous, modified version of a Microsoft DLL
to my customers, however right now it seems to be the most feasible solution.
Sincerely,
Kevin Wienhold