Jump to content
Fórum Script Brasil
  • 0
Sign in to follow this  
Guest Víctor Castro

Como Finalizar Uma Tarefa Pelo Vb6

Question

Guest Víctor Castro

Gostaria de saber se alguém sabe como finalizar uma tarefa, uma das que aparece na task manager? Mas eu quero finalizar a tarefa que eu quiser.

Muito obrigado,

Víctor Castro

Share this post


Link to post
Share on other sites

1 answer to this question

Recommended Posts

  • 0

uma forma de fechar aplicativos é

usando a API do Windows.

Copie o exemplo abaixo , crie um novo projeto , coloque um label, um command button e um text box no seu projeto.

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Const SW_SHOWNORMAL = 1
Const WM_CLOSE = &H10

Private Sub Command1_Click()
'*********************************************************
             ret = CStr(Text1)
'Aqui fecha todas as janelas
'WinWnd = FindWindow(vbNullString, ret)
'Aqui fecha uma janela especifica 
 WinWnd = FindWindow("NomeDaJanela", ret)
  
 If WinWnd = 0 Then
  Label1.Caption = "Janela não encontrada..."
Else
 ShowWindow WinWnd, SW_SHOWNORMAL
 'lpClassName = Space(256)
  Label1.Caption = "Class name: " & ret 'Left$(lpClassName, CStr(ret))
End If
PostMessage WinWnd, WM_CLOSE, 0&, 0&
'********************************************************
End Sub

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  



  • Forum Statistics

    • Total Topics
      148104
    • Total Posts
      643375
×
×
  • Create New...