http://www.cnblogs.com/Jesses/articles/1636323.html
引用PsAPI
var
h:HWND;
pid: Cardinal;
pHandle: THandle;
buf: array[0..MAX_PATH] of Char;
begin
h:=GetForegroundWindow; //获取当前激活的窗体句柄
GetWindowThreadProcessId(h, @pid); //通过句柄获取其进程ID
pHandle := OpenProcess(PROCESS_ALL_ACCESS, False, pid);//通过进程ID获取进程句柄
GetModuleFileNameEx(pHandle, 0, buf, Length(buf));//通过进程句柄获取其模块路径
CloseHandle(pHandle);
Edit1.Text:= buf;
end;//把它放进一个Timer里,半秒获取一次。。。
另加个Spy++模式的Delphi源码