Newsgroups : Borland : borland.public.delphi.rtl.win32 : 2008 May : XP code broken in Vista: How do you add a column to Explorer?
| Subject: | XP code broken in Vista: How do you add a column to Explorer? |
| Posted by: | "Mark Patterson" (noe_zp..@stopbots.org) |
| Date: | Thu, 29 May 2008 14:39:04 |
Hi,
In our system we have been storing emails from Outlook on the file
system, and to make them easy to identify we added a Title column in
Explorer which takes the subject of the emails.
The code to do it is here:
{Based on code from Delphi3000 and Remy Lebeau, Team-B}
procedure SetFileProperty(const FileName, value: widestring; const
FmtID: TGUID; PropID: integer); overload;
var
stg: IStorage;
PropSetStg: IPropertySetStorage;
PropStg: IPropertyStorage;
PropSpec: TPropSpec; // record
PropVariant: TPropVariant; // record
hRes: HResult;
begin
OleCheck(StgOpenStorage(PWideChar(FileName),nil,
STGM_SHARE_EXCLUSIVE or STGM_READWRITE, nil, 0, stg));
PropSetStg := Stg as IPropertySetStorage;
hRes := PropSetStg.Open(FmtID, STGM_READWRITE or
STGM_SHARE_EXCLUSIVE, PropStg);
if hRes = STG_E_FILENOTFOUND then
hRes := PropSetStg.Create(FmtID, FmtID, PROPSETFLAG_DEFAULT,
STGM_CREATE or STGM_READWRITE or STGM_SHARE_EXCLUSIVE, PropStg);
OleCheck(hRes);
PropSpec.ulKind := PRSPEC_PROPID;
PropSpec.propid := PropID;
PropVariant.vt := VT_LPWSTR;
PropVariant.pwszVal := PWideChar(value);
OleCheck(PropStg.WriteMultiple(1, @PropSpec, @PropVariant, 2));
PropStg.Commit(STGC_DEFAULT);
end;// SetFileProperty ---------------------
called from this
procedure SetNTFSTitle(const FileName, Title: string);
begin
SetFileProperty(FileName, Title, GUIDSummaryInformation, PID_TITLE);
end;// SetNTFSTitle
Something similar is done for the Author column.
The trouble is that in while these values show up in Explorer in good
ole' XP, they don't in Vista. Any ideas?
--
Mark Patterson
www.piedsoftware.com