I need to use the method IsPathCacheable in the IOfflineFilesCache interface to check to see if a UNC path is being cached:
http://msdn.microsoft.com/en-us/library/bb530497%28v=VS.85%29.aspx
Has anyone defined this interface for use in Delphi (I'm using Delphi 2010) or know of another way to achieve thi开发者_如何学Pythons (aside from defining it myself)?
Thanks
You can use WMI to access offline files: The Win32_OfflineFilesItem
class can be used to enumerate them and inspect their properties.
To spare you the hassle of setting up WMI for yourself I would suggest the excellent Delphi WMI Class Generator. It will generate the unit uWin32_OfflineFilesItem.pas containing a wrapper class called TWin32_OfflineFilesItem
which can be used as follows:
uses uWin32_OfflineFilesItem;
var
OfflineItems: TWin32_OfflineFilesItem;
i: Integer;
begin
OfflineItems:= TWin32_OfflineFilesItem.Create;
for i:= 0 to OfflineItems.GetCollectionCount-1 do
begin
OfflineItems.SetCollectionIndex(i);
Memo1.Lines.Add(OfflineItems.ItemPath); // <-- this gives the UNC path
end;
end;
(There is one other unit involved, uWmiDelphiClass.pas, which comes with the Delphi WMI Class Generator download.)
You can use the same approach to access the methods of Win32_OfflineFilesCache
(which corresponds to IOfflineFilesCache
). Unfortunately there the method IsPathCacheable
is missing, thus the need to use above approach.
精彩评论