//声明:
GetWindowThreadProcessId(
  hWnd: HWND;                  {指定窗口句柄}
  lpdwProcessId: Pointer = nil {返回进程 ID 的指针}
): DWORD;                      {返回线程 ID}

//举例: unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Grids; type TForm1 = class(TForm) procedure FormCreate(Sender: TObject); end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.FormCreate(Sender: TObject); var c: Cardinal; begin GetWindowThreadProcessId(Handle, @c); ShowMessage(IntToStr(c)); {2792; 随机的} {在本例中相同于 GetCurrentProcessID 的结果} c := GetCurrentProcessID; ShowMessage(IntToStr(c)); {2792} c := GetWindowThreadProcessId(Handle, nil); ShowMessage(IntToStr(c)); {2748} {在本例中相同于 GetCurrentThreadID 的结果} c := GetCurrentThreadID; ShowMessage(IntToStr(c)); {2748} end; end.
posted on 2008-03-10 11:59  万一  阅读(18066)  评论(1编辑  收藏  举报