Delphi程序API申明调用及参数传址与传值
unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) btn1: TButton; procedure apitest(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation function MB(hWnd: Integer; lpText, lpCaption: string; uType: Integer): Integer; stdcall; external 'user32.dll' name 'MessageBoxA'; function FW(ClassName, WindowName: string ): Integer; stdcall; external 'user32.dll' name 'FindWindowA'; function getthpid(jubing:Integer;var lpid: Integer ): Integer; stdcall; external 'user32.dll' name 'GetWindowThreadProcessId'; {$R *.dfm} procedure TForm1.apitest(Sender: TObject); var i,pid:Integer; begin MB(0,'HellO WorlD','Shellcode的博客',0); i:=FW('扫雷','扫雷'); getthpid(i,pid); ShowMessage(IntToStr(pid)); GetWindowThreadProcessId(i,@pid); ShowMessage(IntToStr(pid)); end; end.