Ir para conteúdo
Fórum Script Brasil
  • 0

Processos No Windows 2k


TeoX

Pergunta

E AÍ GALERA! SOU NOVO NA ÁREA.

SERÁ QUE ALGUÉM AÍ SABE COMO POSSO IDENTIFICAR SE UM PROCESSO ESTÁ SENDO EXECUTADO ???

O IDEAL SERIA EU TER UMA FUNÇÃO BOOLEANA QUE ME RETORNE SE UM PROCESSO ESTÁ OU NÃO SENDO EXECUTADO.

ESTOU UTILIZANDO O DELPHI 6.0 E WINDOWS 2000.

OBRIGADO,

TEOX :huh:

Link para o comentário
Compartilhar em outros sites

1 resposta a esta questão

Posts Recomendados

  • 0

OK PESSOAL...!

DESCOBRI UMA SOLUÇÃO PARA O MEU PROBLEMA... PARA QUEM PRECISAR, LOGO ABAIXO ESTÁ O FONTE DE UMA UNIT.

FOI UTILIZADO FUÑÇÕES DA API DO WINDOWS: USER32

BASTA CRIAR UM FORMULÁRIO COM UM BUTTON, UM LABEL E UM LISTBOX.

unit Upid;

interface

uses

Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

Dialogs, StdCtrls;

type

TForm1 = class(TForm)

Button1: TButton;

Label1: TLabel;

ListBox1: TListBox;

procedure Button1Click(Sender: TObject);

procedure ListBox1Click(Sender: TObject);

private

{ Private declarations }

public

{ Public declarations }

end;

var

Form1: TForm1;

implementation

{$R *.DFM}

Function EnumWindowsProc (Wnd: HWND; lb: TListbox): BOOL; stdcall;

var

caption: Array [0..128] of Char;

begin

Result := True;

if { skip invisible windows }

IsWindowVisible(Wnd) and

{ only process truly top-level windows. GetWindowLong must be used, not

GetParent }

((GetWindowLong(Wnd, GWL_HWNDPARENT) = 0) or

(HWND(GetWindowLong(Wnd, GWL_HWNDPARENT)) = GetDesktopWindow)) and

{ skip WS_EX_TOOLWINDOW windows }

((GetWindowLong(Wnd, GWL_EXSTYLE) and WS_EX_TOOLWINDOW) = 0)

then begin

SendMessage( Wnd, WM_GETTEXT, Sizeof( caption ), integer(@caption));

lb.Items.AddObject( caption, TObject( Wnd ));

end;

end;

procedure TForm1.Button1Click(Sender: TObject);

begin

listbox1.clear;

EnumWindows( @EnumWindowsProc, integer( listbox1 ));

end;

procedure TForm1.ListBox1Click(Sender: TObject);

var

theClassname: Array [0..128] of Char;

Wnd: HWND;

tid, pid: DWORD;

begin

With Sender As TListbox Do Begin

If ItemIndex >= 0 Then Begin

Wnd:= HWND(Items.Objects[ itemindex ]);

If Wnd <> 0 Then Begin

Windows.GetClassname( Wnd, theClassname, Sizeof( classname ));

tid := GetWindowThreadProcessID( Wnd, @pid );

label1.caption :=

Format(

'HWND: %8.8x'#13#10+

'Class: %s'#13#10+

'Process ID: %8.8x'#13#10+

'Thread ID: %8.8x',

[Wnd, theClassname, pid, tid] );

End;

End;

End;

end;

end.

Link para o comentário
Compartilhar em outros sites

Participe da discussão

Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.



  • Estatísticas dos Fóruns

    • Tópicos
      152,1k
    • Posts
      651,8k
×
×
  • Criar Novo...