Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
4334 connectés 

 


Dernière réponse
Sujet : [VB6] API
_GrEgY_ pq tu ne prends pas Me.parent.hwnd   tu as le handle parent de ta fenetre pas besoin de passer par des api...

Votre réponse
Nom d'utilisateur    Pour poster, vous devez être inscrit sur ce forum .... si ce n'est pas le cas, cliquez ici !
Le ton de votre message                        
                       
Votre réponse


[b][i][u][strike][spoiler][fixed][cpp][url][email][img][*]   
 
   [quote]
 

Options

 
Vous avez perdu votre mot de passe ?


Vue Rapide de la discussion
_GrEgY_ pq tu ne prends pas Me.parent.hwnd   tu as le handle parent de ta fenetre pas besoin de passer par des api...
Bendes C'est bon, en employant juste l'API "FindWindow" j'ai juste ce qu'il me faut, ça marche avec l'exécutable et il y a moins de ligne de code...;)
 
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
 
if FindWindow(vbNullString, "Mon appli" ) = 0 then Launch
Bendes Thx, j'vais tester ça...
mid La seul différence ca à l'air d'être :
 
CurrWnd = RecupLaFenetre(frm_principale.hwnd, 0)
mid J'essayé ton code, ca me fais pareil.
Voici ce que j'ai trouvé qui marche (faut le convertir pour que ca fasse la même chose)
 
Private Declare Function RecupLaFenetre Lib "user32" Alias "GetWindow" _
                        (ByVal hwnd As Long, ByVal wCmd As Long) As Long
Private Declare Function RecupLePidDuPapa Lib "user32" Alias "GetParent" _
                                              (ByVal hwnd As Long) As Long
Private Declare Function RecupLaLongueurDeLeTexte Lib "user32" Alias _
                   "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
Private Declare Function RecupLeTexte Lib "user32" Alias "GetWindowTextA" _
  (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Private Declare Function ModifLeTexte Lib "user32" Alias "SetWindowTextA" _
                     (ByVal hwnd As Long, ByVal lpString As String) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
   (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function SendMessageA Lib "user32" (ByVal hwnd As Integer, _
      ByVal wMsg As Integer, ByVal wParam As Integer, lParam As Any) As Long
 
 
Sub LoadTaskList()
 Dim CurrWnd As Long
 Dim LongueurDeLeNom As Long
 Dim TaskName As String
 Dim Parent As Long
 
 CurrWnd = RecupLaFenetre(frm_principale.hwnd, 0)
 gIndex = 0
 While CurrWnd <> 0
  Parent = RecupLePidDuPapa(CurrWnd)
  LongueurDeLeNom = RecupLaLongueurDeLeTexte(CurrWnd)
  TaskName = Space$(LongueurDeLeNom + 1)
  Length = RecupLeTexte(CurrWnd, TaskName, LongueurDeLeNom + 1)
  TaskName = Left$(TaskName, Len(TaskName) - 1)
  If Length > 0 And gIndex < 200 Then
   'If TaskName <> Me.Caption Then
   frm_principale.List1.AddItem TaskName
   gIndex = gIndex + 1
  End If
  CurrWnd = RecupLaFenetre(CurrWnd, 2)
  DoEvents
 Wend
End Sub
Bendes Personne...:(
 
C'est vrai que c'est bizarre comme comportement, et je ne vois pas du tout d'où ça peut venir....
Bendes Voici mon code :
 
Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Private Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
Private Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long
Private Declare Function GetActiveWindow Lib "user32" () As Long
 
Public Function TaskExists(ByVal strCheckTask As String) As Boolean
Dim CurrWnd As Long
Dim Length As Long
Dim TaskName As String
TaskExists = False
CurrWnd = GetActiveWindow()
Do While (CurrWnd <> 0)
 Length = GetWindowTextLength(CurrWnd)
 TaskName = Space(Length + 1)
 Length = GetWindowText(CurrWnd, TaskName, Length + 1)
 TaskName = Left(TaskName, Len(TaskName) - 1)
 If (Length > 0) Then
  If InStr(1, TaskName, strCheckTask, vbTextCompare) <> 0 Then
   TaskExists = True
   Exit Do
  End If
 End If
 CurrWnd = GetWindow(CurrWnd, 2) '\2 = next window handle
Loop
End Function
 
Cette fonction permet de savoir mon l'application est déjà démarrer ou pas (via API)
 
Le prob est que sous environement VB ça marche nickel, ms qd je créé l'exécutable, ça marche plus, POURQUOIIII??? :(:(:(:(:(

Copyright © 1997-2025 Groupe LDLC (Signaler un contenu illicite / Données personnelles)