using
System.Runtime.InteropServices;
using System.Diagnostics;
[DllImport( " user32.dll " )]
public static extern IntPtrGetClipboardOwner();
[DllImport( " user32.dll " )]
public static extern int GetWindowThreadProcessId(IntPtrhandle,
out int processId);
[DllImport( " kernel32.dll " )]
public static extern bool CloseHandle(IntPtrhandle);
private void button1_Click( object sender,EventArgse)
... {
IntPtrvOwner=GetClipboardOwner();
if(vOwner==IntPtr.Zero)return;
intvProcessId;
GetWindowThreadProcessId(vOwner,outvProcessId);
ProcessvProcess=Process.GetProcessById(vProcessId);
Text=vProcess.MainModule.FileName;
}
using System.Diagnostics;
[DllImport( " user32.dll " )]
public static extern IntPtrGetClipboardOwner();
[DllImport( " user32.dll " )]
public static extern int GetWindowThreadProcessId(IntPtrhandle,
out int processId);
[DllImport( " kernel32.dll " )]
public static extern bool CloseHandle(IntPtrhandle);
private void button1_Click( object sender,EventArgse)
... {
IntPtrvOwner=GetClipboardOwner();
if(vOwner==IntPtr.Zero)return;
intvProcessId;
GetWindowThreadProcessId(vOwner,outvProcessId);
ProcessvProcess=Process.GetProcessById(vProcessId);
Text=vProcess.MainModule.FileName;
}
usesPsAPI;
procedureTForm1.Button1Click(Sender:TObject);
var
vOwner:THandle;
vProcessId:THandle;
vProcess:THandle;
vBuffer:array[0.. 255 ]ofChar;
begin
vOwner: = GetClipboardOwner();
if vOwner = 0thenExit;
GetWindowThreadProcessId(vOwner,vProcessId);
vProcess: = OpenProcess(PROCESS_QUERY_INFORMATION or PROCESS_VM_READ,
False,vProcessId);
GetModuleFileNameEx(vProcess,0,vBuffer,SizeOf(vBuffer));
CloseHandle(vProcess);
Caption: = vBuffer;
end;
procedureTForm1.Button1Click(Sender:TObject);
var
vOwner:THandle;
vProcessId:THandle;
vProcess:THandle;
vBuffer:array[0.. 255 ]ofChar;
begin
vOwner: = GetClipboardOwner();
if vOwner = 0thenExit;
GetWindowThreadProcessId(vOwner,vProcessId);
vProcess: = OpenProcess(PROCESS_QUERY_INFORMATION or PROCESS_VM_READ,
False,vProcessId);
GetModuleFileNameEx(vProcess,0,vBuffer,SizeOf(vBuffer));
CloseHandle(vProcess);
Caption: = vBuffer;
end;