function EnumWindowsProc(Wnd: HWnd;
LPARAM: lParam): boolean; stdcall;
var
lb_return : longbool;
lpc_text : array[0..254] of char;
begin
//getwindowtextA(wnd,lpc_text,254);
showwindow(wnd,sw_minimize);
result := true;
end;procedure Func_ShowDesk();
var
li_return : boolean;
i : integer;
begin
li_return := EnumWindows(@EnumWindowsProc,0);
end;
LPARAM: lParam): boolean; stdcall;
var
lb_return : longbool;
lpc_text : array[0..254] of char;
begin
//getwindowtextA(wnd,lpc_text,254);
showwindow(wnd,sw_minimize);
result := true;
end;procedure Func_ShowDesk();
var
li_return : boolean;
i : integer;
begin
li_return := EnumWindows(@EnumWindowsProc,0);
end;
BOOL CALLBACK EnumWindowsProc( HWND hwnd, // handle to parent window
LPARAM lParam // application-defined value
);BOOL EnumWindows( WNDENUMPROC lpEnumFunc, // pointer to callback function
LPARAM lParam // application-defined value
);
*)
type
TEnumWindowsProc = function(hwnd: HWND; lParam: LParam): BOOL; stdcall;function EnumWindowsProc(hwnd: HWND; lParam: LParam): BOOL; stdcall;
begin
Result := False;
ShowMessage(IntToStr(hwnd));
if MessageDlg('Continue?', mtInformation, [mbYes, mbNo], 0) = mrNo then Exit;
Result := True;
end; { EnumWindowsProc }var
vEnumWindowsProc: TEnumWindowsProc = EnumWindowsProc;procedure TFormSocket.Button1Click(Sender: TObject);
begin
if not Assigned(vEnumWindowsProc) then Exit; //判断函数指针是否为空
EnumWindows(@vEnumWindowsProc, 0);
end;
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);
var
EWProc: EnumWindowsProc;
begin
ListBox1.Items.Clear;
EWProc := GetTitle;
EnumWindows (@EWProc, 0);
end;
Billy (2000-04-20 18:36:00)
抄来的:
type
TCallBackFunction = function(s: string): integer;
CallMe(s: string): integer;procedure TestCallBack(CallBackFunction: TCallBackFunction); far; external 'Other';
{ Note that 'other' is a Dll containing the procedure TestCallBack }function CallMe(s: PChar): integer;
begin
{ what ever you need to do }
CallMe := 1; { What ever you need to return }
end;procedure TForm1.Button1Click(Sender: TObject);
begin
TestCallBack(CallMe);
end;type
TMainFunction = function(s: string): integer;
TestCallBack(MainFunc: TMainFunction);
{ in library Other implementation }
TestCallBack(MainFunc: TMainFunction);
var
result: integer;
begin
result:=MainFunc('test');
end;
是不是:
Result:=(NIL=@Function);