Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Image Attributes different under Windows 2000 and Windows XP?

0 views
Skip to first unread message

Robert A. Wlodarczyk

unread,
Mar 3, 2002, 7:41:37 PM3/3/02
to
Hi,

I have a piece of code that I've written in C# that writes the attributes
for JPGs (see below; attributes such as DocTitle, DocComment, DocAuthor,
etc). When I set these attributes under Windows XP, they set correctly (ie:
when you right click the file and goto summary you can see the attributes).
Further, when I run a query against the index server on my Windows XP
machine to search for a file with some attribute (say DocTitle) that I set
in this fashion, it returns the correct result. However, when I copy the
file to my W2K Server and run the same query against my Index Server there,
it doesn't return any results (yes, I copied the file into the correct
folder that's being indexed). Under Windows 2000, when I right click the
file and look at the summary under properties, I don't see any of the
attributes (DocComment, DocAuthor, etc) that I set back and saw in Windows
XP on the same file. When I run my application I wrote in C# to get the
attributes under Windows 2000, it gets them and they're correct. What's
Windows 2000 Server doing differently here? What can I do to have Windows
2000 recognize these attributes like Windows XP is?

BTW, one thing I forgot to mention, in my Index Server search code, I have
the following line:
Console.WriteLine("Index Server Version: " +
dbIdxS.ServerVersion.ToString());

Under both Windows XP and Windows 2000 Server this returns:
Index Server Version: 03.00.0000

If you want, I can email you the entire VS.net projects for code mentioned
here...

Thanks,

Rob.


Here's the C# code:
System.Drawing.Image imgImage Image.FromFile(openFileDialog1.FileName);
System.Drawing.Imaging.PropertyItem[] propAllProperties =
imgImage.PropertyItems;
System.Drawing.Imaging.PropertyItem propTemp = propAllProperties[0];

byte[] Value = System.Text.ASCIIEncoding.Unicode.GetBytes(txtTitle.Text);
propTemp.Id = 40091; // Title ==> DocTitle
propTemp.Len = Value.Length;
propTemp.Value = Value;
imgImage.SetPropertyItem(propTemp);

Value = System.Text.ASCIIEncoding.Unicode.GetBytes(txtComments.Text);
propTemp.Id = 40092; // Comments ==> DocComments
propTemp.Len = Value.Length;
propTemp.Value = Value;
imgImage.SetPropertyItem(propTemp);

Value = System.Text.ASCIIEncoding.Unicode.GetBytes(txtAuthor.Text);
propTemp.Id = 40093; // Author ==> DocAuthor
propTemp.Len = Value.Length;
propTemp.Value = Value;
imgImage.SetPropertyItem(propTemp);

Value = System.Text.ASCIIEncoding.Unicode.GetBytes(txtKeywords.Text);
propTemp.Id = 40094; // Keywords ==> DocKeywords
propTemp.Len = Value.Length;
propTemp.Value = Value;
imgImage.SetPropertyItem(propTemp);

Value = System.Text.ASCIIEncoding.Unicode.GetBytes(txtSubject.Text);
propTemp.Id = 40095; // Subject ==> DocSubject
propTemp.Len = Value.Length;
propTemp.Value = Value;
imgImage.SetPropertyItem(propTemp);

try
{
if(saveFileDialog1.ShowDialog() == DialogResult.OK)
{
imgImage.Save(saveFileDialog1.FileName,
System.Drawing.Imaging.ImageFormat.Jpeg);
}
}
catch(Exception ee)
{
}

C# code for searching the index server:
string sqlQuery = "SELECT path, filename FROM ZENITH.MyIndex..SCOPE() WHERE
DocTitle='Some title'";
OleDbConnection dbIdxS = new OleDbConnection("Provider=msidxs;");
OleDbCommand dbCommand = new OleDbCommand(sqlQuery, dbIdxS);
dbIdxS.Open();
Console.WriteLine("Index Server Version: " +
dbIdxS.ServerVersion.ToString());
OleDbDataReader dbReader = null;
try
{
dbReader = dbCommand.ExecuteReader();
while(dbReader.Read())
{
Console.WriteLine(dbReader.GetValue(0).ToString() + " " +
dbReader.GetValue(1).ToString());
}
}
catch (OleDbException ee)
{
Console.WriteLine(ee.Message);
Console.WriteLine(ee.Source);
}
finally
{
dbReader.Close();
dbIdxS.Close();
}

John Hornick [MS]

unread,
Mar 4, 2002, 9:50:46 AM3/4/02
to
Hi,

> I have a piece of code that I've written in C# that writes the attributes
> for JPGs (see below; attributes such as DocTitle, DocComment, DocAuthor,
> etc). When I set these attributes under Windows XP, they set correctly
(ie:
> when you right click the file and goto summary you can see the
attributes).
> Further, when I run a query against the index server on my Windows XP
> machine to search for a file with some attribute (say DocTitle) that I set
> in this fashion, it returns the correct result. However, when I copy the
> file to my W2K Server and run the same query against my Index Server
there,
> it doesn't return any results (yes, I copied the file into the correct
> folder that's being indexed). Under Windows 2000, when I right click the
> file and look at the summary under properties, I don't see any of the
> attributes (DocComment, DocAuthor, etc) that I set back and saw in Windows
> XP on the same file. When I run my application I wrote in C# to get the
> attributes under Windows 2000, it gets them and they're correct. What's
> Windows 2000 Server doing differently here? What can I do to have Windows
> 2000 recognize these attributes like Windows XP is?


You are using property tags which are reserved for the shell. We do plan
to document those tags though, so you should be able to do things like you
did in the code you shared.

Anyway - the point is that these tags are specific to the shell in XP. So
they may not be recognized on Win2K. I would guess that if it were to work
at all on Win2K, you'd need to install IE6 there. Do you have IE6 on the
Win2K machine? If you have IE6 on the Win2K machine and it still doesn't
work, then you have your answer: "It's an XP-only thing". Otherwise, IE6
will have solved the problem for you.

Thanks,
- John
Microsoft Developer Support
This posting is provided "AS IS" with no warranties, and confers no rights.
Visit http://www.microsoft.com/security for current information on security.

Robert A. Wlodarczyk

unread,
Mar 4, 2002, 4:44:08 PM3/4/02
to
Yep, I have IE6 on the W2K machine too... Oh well, "A Windows XP only
thing". Hopefully Windows .NET Server has this built in too.

Rob.

"John Hornick [MS]" <JohnH...@online.microsoft.com> wrote in message
news:7OEgNw4wBHA.2144@cpmsftngxa09...

John Hornick [MS]

unread,
Mar 7, 2002, 11:03:54 AM3/7/02
to
Hi,

I have a little more information to share on this. I have not personally
verified any of this, but I thought I'd pass it along:

These tags are XP-specific in terms of how they are stored in the file, but
using the IShellFolder interface to bind to IPropertySetStorage for the
given
file and read/write the properties from FMTID_SummaryInformation might work
on
both XP and Win2k. On Win2k the values are stored directly in NTFS property
streams, on XP we use EXIF tags. So on Win2k you might have to bind to the
NTFS IPropertySetStorage using StgOpenStorageEx, although on XP you'll need
to use the IShellFolder::BindToStorage or BindToObject method to get the
right
IPropertySetStorage. The IShellFolder method might work on both - not sure.

A side effect of this is that if you modified those values on Win2k you
won't
see them on the prop sheet in XP.


I can't add any more than that - I got this information from our development
group, and pretty much copy/pasted it above. I hope it helps.

Robert A. Wlodarczyk

unread,
Mar 10, 2002, 10:00:17 AM3/10/02
to
Great. Thank you!

Rob.

"John Hornick [MS]" <JHor...@online.microsoft.com> wrote in message
news:HYe9fGfxBHA.2528@cpmsftngxa07...

0 new messages