function SHChangeNotifyRegister(hWnd:HWND; dwFlags:Integer;
wEventMask:Cardinal; uMsg:UINT; cItems:Integer;
lpItems:PNotifyRegister):HWND; stdcall; external Shell32 index 2;
function SHILCreateFromPath(pszPath:PChar; ppidl:PItemIDList;
rgflnOut:PDWORD):HResult; stdcall; external Shell32 index 28;
var
FNotifyHandle: THandle;
procedure SHChangeRegister(const Handle, uMsg: Cardinal; const FilePath: string);
var
vNotifyRegister: NOTIFYREGISTER;
vAttributes: WORD;
vItemIDList: PItemIDList;
begin
SHILCreatefromPath(PChar(FilePath), @vItemIDList, @vAttributes);
vNotifyRegister.pidlPath := vItemIDList;
vNotifyRegister.bWatchSubtree := True;
FNotifyHandle := SHChangeNotifyRegister(Handle, SHCNF_TYPE or SHCNF_IDLIST,
SHCNE_ALLEVENTS or SHCNE_INTERRUPT, uMsg, 1, @vNotifyRegister);
end;
雖然指定了 filepath,但還是會全盤監視。能不能實作只是監視某個目錄呢?
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/104494.html
標籤:VCL組件開發及應用
