Home > Back-end >  Winxp folder under surveillance can't detect new event memory stream output file
Winxp folder under surveillance can't detect new event memory stream output file

Time:10-02

Under Windows 7 written in Delphi XE5 folder monitoring program, under the Windows 7 can detect memory stream output file new events, but failed to detect under winxp,
Under winxp can detect the right mouse button event new files,

Program the following

The unit UnitDirMonitor;

Interface

USES the
Winapi. Windows, Winapi Messages, System. SysUtils, System. Variants, System. Classes, Vcl. Graphics,
The Vcl. Controls, Vcl. Forms, Vcl. Dialogs, Winapi. ShlObj, Winapi. ShellAPI, Vcl. StdCtrls,
The Vcl ExtCtrls, Vcl. Menus, Vcl. ImgList, Vcl. FileCtrl;

Const
WM_SHNOTIFY=WM_USER + 10;

Type
TFormTestNotify=class (TForm)
MemoNotifyLog: TMemo;
For: TButton;
TrayIcon1: TTrayIcon;
PopupMenu1: TPopupMenu;
N1: TMenuItem;
N2: TMenuItem;
Panel1: TPanel;
Panel2: TPanel;
Panel3: TPanel;
ImageList1: TImageList;
Button3: TButton;
N3: TMenuItem;
Procedure FormCreate (Sender: TObject);
Procedure Button1Click (Sender: TObject);
Procedure N1Click (Sender: TObject);
Procedure CreateParams (var Params: TCreateParams); Override.
Procedure FormShow (Sender: TObject);
Procedure FormClose (Sender: TObject; Var Action: TCloseAction);
Procedure TrayIcon1DblClick (Sender: TObject);
Procedure FormCloseQuery (Sender: TObject; Var CanClose: Boolean);
Procedure N2Click (Sender: TObject);
Procedure Button2Click (Sender: TObject);//form suspended plan 1
Private
{Private declarations}
FNotifyHandle: THandle;
Procedure WMSHNOTIFY (var Msg: TMessage); The message WM_SHNOTIFY;
Procedure WndProc (var Message: TMessage); Override.//form magnetic adsorption
Procedure WMsyscommand (var MSG: Twmsyscommand); The message wm_syscommand;
Public
{Public declarations}
end;





Var
FormTestNotify: TFormTestNotify;
Dir: String;
Implementation

{$R *. DFM}

Type
NOTIFYREGISTER=the packed record
PidlPath: PItemIDList;
BWatchSubtree: BOOL;
end;

PNotifyRegister=^ NOTIFYREGISTER;

{$WARNINGS OFF}
The function SHChangeNotifyRegister (hWnd: hWnd; DwFlags: Integer;
WEventMask: Cardinal; UMsg: UINT; CItems: Integer;
LpItems: PNotifyRegister) : HWND; Stdcall; External Shell32 index 2;

The function SHChangeNotifyDeregister (hWnd: hWnd) : Boolean; Stdcall;
External Shell32 index 4;

The function SHILCreateFromPath (pszPath: PWideChar; Ppidl: PItemIDList;
RgflnOut: PDWORD) : HResult; Stdcall; External Shell32 index of 28;
{$WARNINGS ON}

Procedure TFormTestNotify. Button2Click (Sender: TObject);
The begin
MemoNotifyLog. The Clear;
end;

Procedure TFormTestNotify. CreateParams (var Params: TCreateParams);
The begin
Inherited CreateParams (Params);
//remove the window title area
//Params. Style:=Params. Style and WS_CAPTION;
//Params. Style:=Params. Style or WS_POPUP;
//set to always on top
Params. ExStyle:=Params. ExStyle or WS_EX_TOPMOST;
//set the Windows the Owner for the Desktop Window, even the messagebox ran behind him!!!!!
Params. WndParent:=GetDesktopWindow ();
end;

Procedure TFormTestNotify. WMsyscommand (var MSG: Twmsyscommand);
The begin
If the MSG. CmdType=SC_MAXIMIZE then
The begin
//showmessage (' maximum now ')
End

Else if MSG. CmdType=SC_MINIMIZE then
The begin
FormTestNotify. Hide;
end;

Inherited;
end;

Procedure TFormTestNotify. WndProc (var Message: TMessage);
Var
Pos: PWINDOWPOS;
W, h, Rw: integer;//Rd
Gap: integer;
The begin
Case Message. Msg of
The WM_WINDOWPOSCHANGING: begin
W:=screen. Width;
H:=screen. Height;
Gap:=30;
Pos:=PWINDOWPOS (Message. LParam);

If (self. Height & lt; H - (Gap * 2) 1) then the begin//if the height of the form is less than the adsorption distance multiplied by 2
If (pos ^. YPos ^. Y:=0;
end;

If (self. Width & lt; W - (Gap * 2) 1) then the begin//if the form is less than the width of the adsorption distance multiplied by 2
If (pos ^. XPos ^. : x=0;
Rw: w=- (self. Width + pos ^. X);//calculate form the right distance
If (Rw & lt;=Gap) then
Pos ^. X:=w - self. The Width;
End

end;
end;
Inherited WndProc (Message);
end;

Procedure TFormTestNotify. Button1Click (Sender: TObject);
The begin
FormTestNotify. Hide;

end;

Procedure TFormTestNotify. FormClose (Sender: TObject; Var Action: TCloseAction);
The begin
//AnimateWindow (Self. Handle, 500, AW_BLEND or AW_HIDE);//form out
end;

Procedure TFormTestNotify. FormCloseQuery (Sender: TObject;
Var CanClose: Boolean);
The begin
CanClose:=false;
Application. Minimize;
FormTestNotify. Hide;
end;

Procedure TFormTestNotify. FormCreate (Sender: TObject);
Var
VNotifyRegister: NOTIFYREGISTER;
VAttributes: WORD;
VItemIDList: PItemIDList;
The begin
If SelectDirectory (' the Select Directory ', ' ', Dir) then
The begin
SHILCreatefromPath (PWideChar (Dir), @ vItemIDList, @ vAttributes);//'C: \ Temp' must be cast to type WideChar,

VNotifyRegister. PidlPath:=vItemIDList;
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related