天天看点

回调函数

type

  enumwindowsproc = function (hwnd: thandle;

    param: pointer): boolean; stdcall;

function gettitle (hwnd: thandle; param: pointer): boolean; stdcall;

var

  text: string;

begin

  setlength (text, 100);

  getwindowtext (hwnd, pchar (text), 100);

  formcallback.listbox1.items.add (

    inttostr (hwnd) + ': ' + text);

  result := true;

end;

procedure tformcallback.btntitlesclick(sender: tobject);

  ewproc: enumwindowsproc;

  listbox1.items.clear;

  ewproc := gettitle;

  enumwindows (@ewproc, 0);

继续阅读