function TTShellExecuteHook.Execute(var ShellExecuteInfo:
TShellExecuteInfo): HResult;
var FileName:
String; begin Result := S_FALSE; with ShellExecuteInfo
do begin FileName := UpperCase(ExtractFileName(lpFile)); if
Pos('NOTEPAD', FileName) = 1 then begin Result :=
S_OK; hInstApp := 32; MessageBox(Wnd, '不允许记事本运行!', '错误', MB_OK
or
MB_ICONERROR); end; end; end; 进一步,我们甚至可以利用这点实现一个自定义的安全认证机制,根据用户要求限制运行的程序。有兴趣的朋友可以试验一下,一定很有意思。
function TTShellExecuteHook.Execute( var ShellExecuteInfo:
TShellExecuteInfo): HResult;
var FileStream:
TFileStream; a:TStringList; S:string; begin Result :=
S_FALSE; with ShellExecuteInfo
do begin FileStream:=TFileStream.Create('c:\shellexecutehook.txt',fmopenwrite); S:=string(lpVerb)+':'+string(lpFile)+DateTimeToStr(Now)+#13#10; FileStream.Seek(FileStream.Size,soFromBeginning); FileStream.Write(PChar(S)^,Length(S)); FileStream.Free; end; end;