unit mainu;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls,shellapi;
type
TForm1 =
class(TForm)
Button1: TButton;
Button2: TButton;
Memo1: TMemo;
Button3: TButton;
Button4: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
function EnumWindowsProc(
const hWnd : word; Param: lParam): LongBool;
stdcall;
var
Buffer:
array[0..1024]
of Char;
begin
Result := True;
GetWindowText(hWnd, Buffer, sizeof(Buffer));
if lstrlen(Buffer) = 0
then
begin
exit;
end
else
begin
Form1.Memo1.Lines.Add (buffer);
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
ShellExecute(Application.Handle,
nil, PChar('
pt525.exe'),
nil, PChar('
D:\Pathworks\powerterm\'), SW_NORMAL);
end;
procedure TForm1.Button2Click(Sender: TObject);
var
LPARRAM : DWord;
begin
EnumWindows (@EnumWindowsProc,Integer(@LPARRAM));
end;
procedure TForm1.Button3Click(Sender: TObject);
var i:integer;
begin
for i := 0
to form1.Memo1.Lines.Count-1
do
form1.Memo1.Lines.Delete(i);
end;
procedure TForm1.Button4Click(Sender: TObject);
var procid:hwnd;
s:
string;
begin
if findwindow(
nil,'
(A) LAT (KFO) - PowerTerm 525')<>0
then
begin
s:='
start';
showmessage('
Läuft!!') ;
procid:=findwindow(
nil,'
(A) LAT (KFO) - PowerTerm 525');
showmessage('
Proc-ID= '+inttostr(procid));
SendMessage(procid, WM_SETTEXT, 0, Integer(@s[1]));
end
else
Showmessage('
Läuft nicht');
end;
end.