IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

VB 6 et antérieur Discussion :

[VB6] Gestionnaire des tache de windows 2000 avec VB6


Sujet :

VB 6 et antérieur

  1. #1
    Membre habitué

    Homme Profil pro
    Développeur informatique
    Inscrit en
    Septembre 2002
    Messages
    207
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 37
    Localisation : Suisse

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Septembre 2002
    Messages : 207
    Points : 133
    Points
    133
    Par défaut [VB6] Gestionnaire des tache de windows 2000 avec VB6
    Bonjour,
    j'aimerais savoir si il est possible d'utiliser le gestionnaire de tâche de windows 2000 avec VB6 ,pour savoir par exemple si un porgramme est en train de de s'exécuter ???????

    Merci d'avance
    @@++

  2. #2
    Expert éminent
    Avatar de bidou
    Homme Profil pro
    Développeur .NET
    Inscrit en
    Mai 2002
    Messages
    3 055
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 57
    Localisation : France, Rhône (Rhône Alpes)

    Informations professionnelles :
    Activité : Développeur .NET
    Secteur : Transports

    Informations forums :
    Inscription : Mai 2002
    Messages : 3 055
    Points : 7 962
    Points
    7 962
    Par défaut
    il faut passer par des API pour faire un enum process

  3. #3
    Membre du Club
    Inscrit en
    Novembre 2002
    Messages
    35
    Détails du profil
    Informations personnelles :
    Âge : 50

    Informations forums :
    Inscription : Novembre 2002
    Messages : 35
    Points : 44
    Points
    44
    Par défaut
    Exemple :
    Tu as besoin d'un timer : tmrCheck
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
     
    ''''''''''''
    '  processfinished.bas
    ''''''''''''
    Option Explicit
     
    Public Const PROCESS_QUERY_INFORMATION = 1024
     
    Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
    Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessID As Long) As Long
    Declare Function GetExitCodeProcess Lib "kernel32" (ByVal hProcess As Long, lpExitCode As Long) As Long
     
     
    Public Function TestIfProcessStillAlive(ByVal ProcessID As Long) As Boolean
        Dim Alive_ones              As Long
        Dim LoopTroughProcess       As Long
        Dim hProcess                As Long
        Dim lngExitCode             As Long
     
        If ProcessID <> 0 Then
            hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, False, ProcessID)
            If hProcess <> 0 Then
                GetExitCodeProcess hProcess, lngExitCode
            Else 'process not found
                TestIfProcessStillAlive = False
                Exit Function
            End If
     
            'if you open a handle then you have to close it too
            CloseHandle (hProcess)
        Else
            TestIfProcessStillAlive = False
            Exit Function
        End If
     
        If lngExitCode = 259 Then
            TestIfProcessStillAlive = True
        Else
            If lngExitCode = 0 Then TestIfProcessStillAlive = False
        End If
     
    End Function
     
     
    ''''''''''''''''
    '    frmTest.frm
    '''''''''''''''''
    Option Explicit
     
    Public hnd As Long
     
    Private Sub cmdLaunch_Click()
     
      hnd = Shell("Calc.exe")
     
    End Sub
     
    Private Sub tmrCheck_Timer()
      If hnd <> 0 Then
        If TestIfProcessStillAlive(hnd) Then
          lblCheck = Now() & " - Calculator still running"
        Else
          lblCheck = Now() & " - Calculator STOPPED"
          hnd = 0
        End If
      End If
    End Sub
    La simplicité est la sophistication suprême.

  4. #4
    Membre du Club
    Inscrit en
    Novembre 2002
    Messages
    35
    Détails du profil
    Informations personnelles :
    Âge : 50

    Informations forums :
    Inscription : Novembre 2002
    Messages : 35
    Points : 44
    Points
    44
    Par défaut
    G mieux =)

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
     
    '''''''''''''''
    ''  Project1.vbp
    '''''''''''''''
    Type=Exe
    Form=Form1.frm
    Reference=*\G{00020430-0000-0000-C000-000000000046}#2.0#0#C:\WINNT\System32\STDOLE2.TLB#OLE Automation
    Module=Module1; Module1.bas
    IconForm="frmClassFinder"
    Startup="frmClassFinder"
    HelpFile=""
    ExeName32="WinClass.exe"
    Command32=""
    Name="ClsFinder"
    HelpContextID="0"
    Description="Window spying tool."
    CompatibleMode="0"
    MajorVer=1
    MinorVer=0
    RevisionVer=0
    AutoIncrementVer=0
    ServerSupportFiles=0
    VersionCompanyName="American International Group"
    CompilationType=0
    OptimizationType=0
    FavorPentiumPro(tm)=0
    CodeViewDebugInfo=0
    NoAliasing=0
    BoundsCheck=0
    OverflowCheck=0
    FlPointCheck=0
    FDIVCheck=0
    UnroundedFP=0
    StartMode=0
    Unattended=0
    ThreadPerObject=0
    MaxNumberOfThreads=1
     
     
     
     
     
     
     
     
     
     
    '''''''''''''''
    '   Form1.frm
    ''''''''''''''''
    Option Explicit
     
     
    Private Sub cmdGetClass_Click()
    '----------------------------------------------------------------------------------------------------------
    'This sub locates information about a window when you select
    'it from the list box.
    '----------------------------------------------------------------------------------------------------------
     
    Dim lngHand As Long
    Dim strName As String * 255
    Dim wndClass As wndClass
    Dim lngProcID As Long
    Dim rctTemp As RECT
     
    'Locate the selected window and get its handle.
    lngHand = FindWindow(vbNullString, txtTitle.Text)
     
    'Using the handle obtained from FindWindow, get all class information
    'about the selected window.
    GetClassName lngHand, strName, Len(strName)
     
    'If the name in the text box doesn't match a system window tell the user.
    'Otherwise, get the process id and the window size info.
    If Left$(strName, 1) = vbNullChar Then
         lblClassName.Caption = "Window Not Found!!!"
    Else
         lblClassName.Caption = "Class Name: " & strName
         GetWindowThreadProcessId lngHand, lngProcID
         GetWindowRect lngHand, rctTemp
    End If
     
    'Load the labels with the info retrieved.
    lblProcessID = "ProcessID: " & lngProcID
    lblTop = "Top: " & rctTemp.Top
    lblBottom = "Bottom: " & rctTemp.Bottom
    lblLeft = "Left: " & rctTemp.Left
    lblRight = "Right: " & rctTemp.Right
     
    End Sub
     
     
    Private Sub cmdRefresh_Click()
     
    'Clear the list box and reload it with the current windows.
    lstOpenWindows.Clear
    lblCount.Caption = GetOpenWindowNames & " open Windows."
     
    End Sub
     
     
    Private Sub cmdActivate_Click()
    '----------------------------------------------------------------------------------------------------------
    'This sub activates the selected window.
    '----------------------------------------------------------------------------------------------------------
     
    'Variable to hold the handle to the window.
    Dim lngHand As Long
     
    'Find the window by class or title.
    If Trim$(lblClassName.Caption) = "" Then
         lngHand = FindWindow(vbNullChar, Trim$(txtTitle.Text))
    Else
         lngHand = FindWindow(Right$(lblClassName.Caption, (Len(lblClassName) - 12)), lstOpenWindows.Text)
    End If
     
    'Activate the selected window.
    'Some windows are hidden so it will make the application the input app.
    BringWindowToTop lngHand
     
    End Sub
     
     
     
    Private Sub cmdRefreshClass_Click()
     
    Call cmdGetClass_Click
     
    End Sub
     
    Private Sub Form_Load()
     
    'Make our app the top most window in the system.
    SetWindowPos Me.hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE
     
    'Highlight the text in txtTitle.
    txtTitle.SelLength = Len(txtTitle.Text)
     
    lblCount.Caption = GetOpenWindowNames & " open Windows."
     
    End Sub
     
     
    Private Sub lstOpenWindows_Click()
     
    'Call the hidden cmdGetClass button.
    txtTitle.Text = lstOpenWindows.Text
    Call cmdGetClass_Click
     
    End Sub
     
     
    Private Sub tmrWinClass_Timer()
     
    'Check every 100 ms for the current application int the
    'system and load it's info to our form.
    Dim lngHand As Long
    Dim strName As String * 255
     
    lngHand = GetForegroundWindow
     
    GetWindowText lngHand, strName, Len(strName)
    lblCurrent.Caption = strName
     
    GetClassName lngHand, strName, Len(strName)
    lblClass.Caption = strName
    End Sub
     
     
     
    ''''''''''''''''
    '   Module1.bas
    '''''''''''''
    Option Explicit
     
    '----------------------------------------------------------------------------------------------------------
    'Author:  Jonathan Morrison
    'Date:     6/13/1998
    '----------------------------------------------------------------------------------------------------------
    'This is the main code module.  It contains all of the API declares and CONST's
    '
    'This was done quick and dirty so if I didn't comment something or if there is a bug just let me know @:
    '                                           jonathan.morrison@aig.com
    '                                           OR
    '                                           jonathanm@mindspring.com
    '----------------------------------------------------------------------------------------------------------
     
    'C language TypeDef to hold the information about a Windows class.
    Type wndClass
        style As Long
        lpfnwndproc As Long
        cbClsextra As Long
        cbWndExtra2 As Long
        hInstance As Long
        hIcon As Long
        hCursor As Long
        hbrBackground As Long
        lpszMenuName As String
        lpszClassName As String
    End Type
     
    'C language TypeDef to hold the size information for a given window.
    Type RECT
            Left As Long
            Top As Long
            Right As Long
            Bottom As Long
    End Type
     
     
    'API Declares
    Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, _
                                                            lpdwProcessId As Long) As Long
     
    Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
     
    Declare Function GetClassLong Lib "user32" Alias "GetClassLongA" (ByVal hwnd As Long, _
                                                                      ByVal nIndex As Long) As Long
     
    Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, _
                                                                       ByVal lpWindowName As String) As Long
     
    Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, _
                                                                      ByVal lpClassName As String, _
                                                                      ByVal nMaxCount As Long) _
                                                                      As Long
     
    Declare Function GetDesktopWindow Lib "user32" () As Long
     
    Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long
     
    Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, _
                                                                            ByVal lpString As String, ByVal cch As Long) _
                                                                            As Long
     
    Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, _
                                                                        ByVal dwNewLong As Long) As Long
     
    Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal _
                                                      hWndInsertAfter As Long, ByVal X As Long, _
                                                      ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, _
                                                      ByVal wFlags As Long) As Long
     
    Declare Function GetActiveWindow Lib "user32" () As Long
     
    Declare Function BringWindowToTop Lib "user32" (ByVal hwnd As Long) As Long
     
    Declare Function GetForegroundWindow Lib "user32" () As Long
     
    Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, _
                                                                    ByVal wMsg As Long, ByVal wParam As Long, _
                                                                    lParam As Any) As Long
     
    Declare Function GetClassInfo Lib "user32" Alias "GetClassInfoA" (ByVal hInstance As Long, _
                                                                      ByVal lpClassName As String, _
                                                                      lpWndClass As wndClass) As Long
     
    '----------------------------------------------------------------------------------------------------------
    Public Const WM_ACTIVATE = &H6
    Public Const SWP_NOMOVE = &H2
    Public Const SWP_NOSIZE = &H1
    Public Const HWND_TOPMOST = -1
    Public Const GW_CHILD = 5
    Public Const GW_HWNDNEXT = 2
    '----------------------------------------------------------------------------------------------------------
     
     
     
    Public Function GetOpenWindowNames() As Long
    '----------------------------------------------------------------------------------------------------------
    'Name:        Function GetOpenWindowNames()
    '
    'Purpose:     To retrieve all open windows in the system.
    '
    'Parameters:  N/A
    '
    'Return:      NONE
    '----------------------------------------------------------------------------------------------------------
     
    'Declare local variables
    Dim lngDeskTopHandle As Long    'Used to hold the value of the Desktop handle.
    Dim lngHand As Long             'Used to hold each windows handle as it loops.
    Dim strName As String * 255     'Fixed length string passed to GetWindowText API call.
    Dim lngWindowCount As Long      'Counter used to return the numberof open windows in the system.
     
    'Get the handle for the desktop.
    lngDeskTopHandle = GetDesktopWindow()
     
    'Get the first child of the desktop window.
    '(Note: The desktop is the parent of all windows in the system.
    lngHand = GetWindow(lngDeskTopHandle, GW_CHILD)
     
    'set the window counter to 1.
    lngWindowCount = 1
     
    'Loop while there are still open windows.
    Do While lngHand <> 0
     
         'Get the title of the next window in the window list.
         GetWindowText lngHand, strName, Len(strName)
     
         'Get the sibling of the current window.
         lngHand = GetWindow(lngHand, GW_HWNDNEXT)
     
         'Make sure the window has a title; and if it does add it to the list.
         If Left$(strName, 1) <> vbNullChar Then
              frmClassFinder.lstOpenWindows.AddItem Left$(strName, InStr(1, strName, vbNullChar))
              lngWindowCount = lngWindowCount + 1
         End If
    Loop
     
    'Return the number of windows opened.
    GetOpenWindowNames = lngWindowCount
     
    End Function
    La simplicité est la sophistication suprême.

  5. #5
    Membre habitué

    Homme Profil pro
    Développeur informatique
    Inscrit en
    Septembre 2002
    Messages
    207
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 37
    Localisation : Suisse

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Septembre 2002
    Messages : 207
    Points : 133
    Points
    133
    Par défaut
    Ben ej vous remercie bien pour votre aide..., pour le moment je comprend pas grand chose à tous ce code, alors je vais regarder tous sa et je vous redit...
    @@++
    @@++

  6. #6
    Membre habitué

    Homme Profil pro
    Développeur informatique
    Inscrit en
    Septembre 2002
    Messages
    207
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 37
    Localisation : Suisse

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Septembre 2002
    Messages : 207
    Points : 133
    Points
    133
    Par défaut
    En fait on m'a donner une manière Beaucoup plus simple pour ésoudre mon problème (voir : [Résolut] savoir depuis VB, si un document Excel est ouvert), mais je vous remercie quand meme de vos info, car même si elle ne vont pas me servir tout de suite, je vais certainement les utiliser dans un prochain programme... .

    alors @@++
    @@++

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. activer le gestionnaire des taches windows xp
    Par soujava dans le forum Windows XP
    Réponses: 1
    Dernier message: 02/05/2008, 10h10
  2. probleme avec Gestionnaire des taches
    Par Hamza dans le forum Windows XP
    Réponses: 4
    Dernier message: 28/10/2007, 19h08
  3. Gestionnaire des Taches Windows
    Par redaxis dans le forum Windows XP
    Réponses: 1
    Dernier message: 10/06/2007, 16h22
  4. Réponses: 2
    Dernier message: 20/03/2007, 18h10
  5. Réponses: 3
    Dernier message: 24/11/2006, 13h23

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo