mmilan
asked on
Starting program
How can I detect when some Windows application was started?
Can you send source code, please?
Can you send source code, please?
ASKER
I want to detrect all programs. I want to get a name of strted program!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Here is an easier way that takes only the visible windows that do have a name.....
---------------
function GetWinProc(Handle : HWND; lParam : LPARAM):Boolean;stdcall;
var
Name : array[0..100]of char;
begin
if IsWindowVisible(Handle) then
begin
GetWindowText(Handle, Name, SizeOf(Name));
if not(Name = '') then
form1.listbox1.items.add(N ame);
end;
Result := true;
end;
procedure TForm1.Button1Click(Sender : TObject);
begin
EnumWindows(@GetWinProc,0) ;
end;
----------
Regards,
Viktor Ivanov
---------------
function GetWinProc(Handle : HWND; lParam : LPARAM):Boolean;stdcall;
var
Name : array[0..100]of char;
begin
if IsWindowVisible(Handle) then
begin
GetWindowText(Handle, Name, SizeOf(Name));
if not(Name = '') then
form1.listbox1.items.add(N
end;
Result := true;
end;
procedure TForm1.Button1Click(Sender
begin
EnumWindows(@GetWinProc,0)
end;
----------
Regards,
Viktor Ivanov
Try this.....
//This checks if Notepad is running and if it is then it displays a message
if FindWindow(nil, 'Untitled - Notepad') <> 0 then
ShowMessage('The application is already running');
Regards,
Viktor Ivanov
//This checks if Notepad is running and if it is then it displays a message
if FindWindow(nil, 'Untitled - Notepad') <> 0 then
ShowMessage('The application is already running');
Regards,
Viktor Ivanov
You can use CreateToolhelp32Snapshot, Process32First and
Process32Next to enumerate through the running processes
but these functions are ONLY available in Win95 (?98) not
in NT.
BTW never use the window title to find a window with FindWindow
always use the window-class.
Process32Next to enumerate through the running processes
but these functions are ONLY available in Win95 (?98) not
in NT.
BTW never use the window title to find a window with FindWindow
always use the window-class.
Ok, use this then....
var
H : HWND;
begin
H := FindWindow('Notepad' nil);
if H <> 0 then
ShowMessage('Notepad is already running...');
end;
Regards,
Viktor Ivanov
var
H : HWND;
begin
H := FindWindow('Notepad' nil);
if H <> 0 then
ShowMessage('Notepad is already running...');
end;
Regards,
Viktor Ivanov
do you wanna build a task manager or a process viewer?
Black Death.
Black Death.
I tried to do the following in straight way-without a label, but did not succeed. :
procedure TForm1.Timer1Timer(Sender:
begin
label1.Caption:=inttostr(F
if not (label1.Caption='0') then
showmessage('You''ve opened My Computer');
timer1.enabled:=false//so it'll show the message only once
end;