procedure TPathExplorer.SetPath(
const Value: Widestring);
var
pszDisplayName : lpwstr;
pdwAttributes : DWord;
pdwDummy : DWord;
NewPIDL : PItemIDList;
ShellFolder : IShellFolder;
Objects : IEnumIdList;
ItemIdList : PItemIdList;
bNoError : Boolean;
bNoFound : Boolean;
bNext : Boolean;
displayname: widestring;
begin
ShellFolder := Desktop;
pszDisplayName := StringToOleStr(Value);
pdwAttributes := 0;
bNoFound := True;
bNoError := True;
while bNoFound
and bNoError
do begin
ShellFolder.ParseDisplayName(0,
nil, pszDisplayName, pdwDummy, NewPIDL, pdwAttributes);
bNoFound := NewPIDL <>
nil;
if bNoFound
then begin
bNoError := Succeeded(ShellFolder.EnumObjects(
Handle, SHCONTF_FOLDERS, Objects));
if bNoError
then begin
bNext := False;
while (Objects.Next(1, ItemIdList, pdwDummy) = NOERROR)
and not bNext
do
if (ItemIdList.mkid.cb = NewPIDL.mkid.cb)
and (ItemIdList.mkid.abID[0] = NewPIDL.mkid.abID[0])
then begin
ShellFolder.BindToObject(ItemIdList,
nil, IID_ISHELLFOLDER, pointer(ShellFolder));
bNext := True;
end;
end;
end;
end;
end;