Les Snippets

Connexion

Récupérer le hwnd (handle) à partir du PID (Process ID)

Niveau requis pour utiliser/comprendre cette source : 1 ( Débutant )
Créé le 10/09/2007 16:30:43 et initié par PCPT [Liste]
Date de mise à jour : 24/09/2008 11:46:25
Vue : 5324
Catégorie(s) : API
Langages dispo pour ce code :
- VB6, VBA
- Delphi 5
- Voir tous les langages pour ce code snippet



Langage : VB6 , VBA
Date ajout : 10/09/2007
Posté par PCPT [Liste]
DateMAJ : 24/09/2008
Private Const GW_HWNDNEXT As Long 2&
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As LongByVal lpWindowName As Long) As  Long
Private Declare Function GetParent Lib "user32" (ByVal hwnd As LongAs Long
Private Declare Function GetWindowThreadProcessId Lib  "user32" (ByVal hwnd As Long, lpdwProcessId As Long) As  Long
Private Declare Function GetWindow Lib "user32" (ByVal hwnd As LongByVal wCmd As Long) As  Long
'
Public Function InstanceToWnd(ByVal target_pid As Long) As Long 'API-Guid
    Dim test_hwnd As Long, test_pid As Long, test_thread_id As  Long
    test_hwnd = FindWindow(ByVal 0&ByVal 0&)
    Do While test_hwnd <> 0&
        If GetParent(test_hwnd) = 0& Then
            test_thread_id = GetWindowThreadProcessId(test_hwnd,  test_pid)
            If test_pid = target_pid Then
                InstanceToWnd = test_hwnd
                Exit Do
            End If
        End If
        test_hwnd = GetWindow(test_hwnd, GW_HWNDNEXT)
    Loop
End Function

Remarque :
ce code provient de l'API-Guid

Snippets en rapport avec : Handle, Process, Récupérer, Pid



Codes sources en rapport avec : Handle, Process, Récupérer, Pid

{Visual Basic, VB6, VB.NET, VB 2005} PROCESS THREADS MODULES HANDLES DANS UN TREEVIEW EN .NET ( OUI MADAME )
Cette source est ma première tentative en vb .net. il faut savoir que j'ai pas la msdn .net... Qu'...

{Visual Basic, VB6, VB.NET, VB 2005} MANIPULATION DES PROCESS ET HANDLES - OPTIONS INÉDITES...
Bon ben comme d'habitude, il liste tous les programmes lancés sur l'ordi, même ceux qui sont cachés ...

{Delphi} COMPOSANT TDESKTOP
Ayant lu récemment un excellent livre sur la conception des composants, je vous présente mon nouveau...

{C# / C#.NET} ENVOI DE MESSAGES NET SEND
Envoi de message via la commande Net Send: Liste des ordinateurs présent sur le réseau. Affichage de...

{Visual Basic, VB6, VB.NET, VB 2005} WIN++ OPTIONS AVANCÉES SUR LES FENETRES ET PROCESSUS WINDOWS (CPU LIMITER, CTRL ALT END, METTRE EN PAUSE UN PROCESSUS...)
Bonjour à tous, Voici un programme dont le but est le suivant : Rassembler toutes les petites so...

{C / C++ / C++.NET} UNIX : LISTER LE NOMBRE DE PROCESSUS TOURNANT SUR LA MACHINE
Salut à tous, Petite fonction simple mais utile et commentée qui retourne le nombre de processus ...

{Visual Basic, VB6, VB.NET, VB 2005} TUER UNE/DES SESSION(S) CACHÉE(S) D'EXCEL À PARTIR D'UNE AUTRE SESSION
Cette source(fichier excel) permet d'arreter une ou plusieurs session excel caché et ce a partir d'u...

{Visual Basic, VB6, VB.NET, VB 2005} CPU LIMITER - LIMITEZ L'UTILISATION DU PROCESSEUR DE CHAQUE PROCESSUS
-------------------------------- MAJ : Une version plus complète de ce programme existe : http://w...

{Visual Basic, VB6, VB.NET, VB 2005} CONTROL_PROCESS PROCESS_VIEWER
c'est un ensemble de code source que g assembler et compiler il permet de voir grace à des fichiers...

{Visual Basic, VB6, VB.NET, VB 2005} CHANGEDESKTOP: CHANGEMENT DE L'APPARENCE DE LA LISTVIEW DU BUREAU WINDOWS
Bonjour, Cette petite source d'une simplicité enfantine vous permettra de changer l'apparence de ...