不好意思我记错了,十分对不起,可以用HOOK吗:<br><br>unit Unit1;<br><br>interface<br><br>uses<br> Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,<br> Dialogs, StdCtrls, ExtCtrls;<br><br>type<br> TForm1 = class(TForm)<br> btnAppMsgBox: TButton;<br> Memo1: TMemo;<br> OpenDialog: TOpenDialog;<br> btnMsgBox: TButton;<br> procedure btnAppMsgBoxClick(Sender: TObject);<br> procedure FormCreate(Sender: TObject);<br> procedure FormDestroy(Sender: TObject);<br> procedure btnMsgBoxClick(Sender: TObject);<br> private<br> { Private declarations }<br> public<br> { Public declarations }<br> end;<br><br> function HookMessageBox(code: integer; wParam: WPARAM; lParam: LPARAM): LRESULT; stdcall;<br><br>var<br> Form1: TForm1;<br> HookMsgBox: DWORD = 0;<br><br>implementation<br><br>{$R *.dfm}<br><br>function GetWindowClassName(H:Thandle):string;<br>var<br> buf: array[0..255] of char;<br>begin<br> GetClassName(H, buf, SizeOf(buf));<br> result:=buf;<br>end;<br><br>function HookMessageBox(code: integer; wParam: WPARAM; lParam: LPARAM): LRESULT;<br>var<br> H: Thandle;<br> PCW: ^CBT_CREATEWND;<br>begin<br> if (code>=0) and (code=HCBT_CREATEWND) then<br> begin<br> H := Thandle(wParam);<br> PCW:=Pointer(lparam);<br> if (GetWindowClassName(H)='#32770')<br> and ((GetWindowLong(H, GWL_STYLE) and WS_SIZEBOX) = 0) //边框不可以缩放<br> and (PCW^.lpcs^.hwndParent=Application.Handle) //检查是不是 Application.MessageBox<br> then Form1.Memo1.Lines.Add(GetWindowClassName(H));<br> end;<br> Result:=CallNextHookEx(HookMsgBox, Code, wParam, lParam);<br>end;<br><br>procedure TForm1.btnAppMsgBoxClick(Sender: TObject);<br>begin<br> Application.MessageBox('test', 'test');<br>end;<br><br>procedure TForm1.FormCreate(Sender: TObject);<br>begin<br> HookMsgBox:=SetWindowsHookEx(WH_CBT,HookMessageBox,0, GetCurrentThreadID);<br>end;<br><br>procedure TForm1.FormDestroy(Sender: TObject);<br>begin<br> if HookMsgBox<>0 then UnhookWindowsHookEx(HookMsgBox);<br>end;<br><br>procedure TForm1.btnMsgBoxClick(Sender: TObject);<br>begin<br> MessageBox(Handle, 'test', 'test', 0);<br>end;<br><br>end.