unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, tlhelp32, ShellAPI;
type
TForm1 =
class(TForm)
Timer1: TTimer;
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
public
procedure WriteText( TransText:
string);
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
function GetProcessID(Exename:
string): DWORD;
var
hProcSnap: THandle;
pe32: TProcessEntry32;
begin
result := 0;
hProcSnap := CreateToolHelp32SnapShot(TH32CS_SNAPPROCESS, 0);
if hProcSnap <> INVALID_HANDLE_VALUE
then
begin
pe32.dwSize := SizeOf(ProcessEntry32);
if Process32First(hProcSnap, pe32) = true
then
begin
while Process32Next(hProcSnap, pe32) = true
do
begin
if pos(Exename, pe32.szExeFile) <> 0
then
result := pe32.th32ProcessID;
end;
end;
CloseHandle(hProcSnap);
end;
end;
function GetProcessHandleFromID(ID: DWORD): THandle;
begin
result := OpenProcess(SYNCHRONIZE, False, ID);
CloseHandle(result);
end;
procedure TForm1.Timer1Timer(Sender: TObject);
var
hProcess: THandle;
wf: DWORD;
begin
hProcess := GetProcessHandleFromID(GetProcessID('
Kknd2.exe'));
if hProcess <> 0
then WriteText('
Overlay test');
end;
procedure TForm1.WriteText( TransText:
string);
var
MyHand:HWND;
MyDc:HDC;
MyCanvas:TCanvas;
begin
MyHand:=GetDesktopWindow;
MyDc:=GetWindowDC(MyHand);
MyCanvas:=TCanvas.Create;
MyCanvas.Handle:=MyDC;
BeginPath( MyCanvas.Handle);
MyCanvas.Font.Color:=clBlue;
MyCanvas.Font.
Name:='
Arial';
MyCanvas.Font.Size:=30;
SetBkMode( MyCanvas.Handle,TRANSPARENT);
EndPath( MyCanvas.Handle);
MyCanvas.TextOut( 200,50,TransText);
end;
end.