Code corrigé
Code : Tout sélectionner
Procedure.s GetPIDExePath(hwnd.l)
;PAPPIP
PID.l=0
GetWindowThreadProcessId_(hwnd,@PID)
hProcess.l=OpenProcess_(#PROCESS_ALL_ACCESS,0,PID);
Name.s=Space(256)
If OpenLibrary(0,"PSAPI.DLL")
*F=GetFunction(0,"GetModuleFileNameExA")
If *F
CallFunctionFast(*F,hProcess,0,@Name,#MAX_PATH)
Else
MessageRequester ("Erreur PSAPI.DLL" ,"Fonction GetModuleFileNameExA non trouvé",0)
CloseLibrary(0)
End
EndIf
Else
MessageRequester ("Erreur PSAPI.DLL" ,"Library non ouverte",0)
End
EndIf
ProcedureReturn Str(PID)+"@"+Name
EndProcedure
Procedure IsFirefox()
Shared.s NOM_exe_path, NOM_EXE, nom_WND
hwnd = FindWindow_(0,0)
While hwnd <> 0
If GetWindowLong_(hwnd,#GWL_STYLE) & #WS_VISIBLE=#WS_VISIBLE
If GetWindowLong_(hwnd,#GWL_EXSTYLE) & #WS_EX_TOOLWINDOW <> #WS_EX_TOOLWINDOW
nom_WND = Space(#MAX_PATH)
GetWindowText_(hwnd,@nom_WND,#MAX_PATH)
; hwndp.l = GetParent_(hwnd)
If nom_WND <> ""
PID_NOM_EXE_PATH.s = GetPIDExePath(hwnd)
PID = Val(StringField(PID_NOM_EXE_PATH, 1, "@"))
NOM_exe_path = StringField(PID_NOM_EXE_PATH, 2, "@")
Debug NOM_exe_path
NOM_EXE = GetFilePart(NOM_exe_path)
If NOM_EXE = "firefox.exe"
FEN.l = FindWindow_(#Null,nom_WND)
Debug ShowWindow_(FEN,#SW_MAXIMIZE)
Debug "Nom fenêtre : " + nom_WND
Debug "***** "+NOM_exe_path+ " **********"
ProcedureReturn 1
EndIf
EndIf
EndIf
EndIf
hwnd = GetWindow_(hwnd,#GW_HWNDNEXT)
Wend
ProcedureReturn 0
EndProcedure
If IsFirefox() = 0
MessageRequester("Erreur","Firefox n'est pas ouvert ! " + Chr(34) + "Vous devez d'abord ouvrir Firefox puis relancer ce logiciel",#MB_OK)
EndIf