#MyApp="Your message"
Mutex=CreateMutex_(0,1,#MyApp)
If GetLastError_()=#ERROR_ALREADY_EXISTS
MessageRequester(#MyApp,"Une seule instance peut être exécutée",#PB_MessageRequester_Error)
End
EndIf
; your main code
#MAIN_FORM = 0
OpenWindow(#MAIN_FORM,0,0,800,600,"Hello world",#PB_Window_ScreenCentered|#PB_Window_SystemMenu)
Repeat
WaitWindowEvent()
Until Event() = #PB_Event_CloseWindow
; don't forget to unlock the mutex
ReleaseMutex_(Mutex)
End
Dernière modification par microdevweb le lun. 24/févr./2020 14:44, modifié 1 fois.
; Code créer par microdevweb le: 24/Fév/2020.
; Code revue et corrigé par Dieppedalle David le: 24/Fév/2020.
#MyApp = "Chaîne"
Mutex = CreateMutex_(0, 1, #MyApp)
If GetLastError_() = #ERROR_ALREADY_EXISTS
MessageRequester(#MyApp, "ATTENTION: Une seule instance peut être exécutée à la fois sur cette machine !", #PB_MessageRequester_Error)
End
EndIf
If OpenWindow(0, 100, 200, 400, 300, "Ma fenêtre", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget)
Repeat
Event = WaitWindowEvent(1)
If Event = #PB_Event_CloseWindow ; If the user has pressed on the close button
Quit = 1
EndIf
Until Quit = 1
EndIf
ReleaseMutex_(Mutex)
Merci pour le partage, justement j'en avais besoin pour mon carnet de surveillance, ça tombe plutôt bien.
Microsoft Windows 10 Famille 64 bits : Carte mère : ASRock 970 Extreme3 R2.0 : Carte Graphique NVIDIA GeForce RTX 3080 : Processeur AMD FX 6300 6 cœurs 12 threads 3,50 GHz PB 5.73 PB 6.00 LTS (x64)
Un homme doit être poli, mais il doit aussi être libre !
C'est pas bête cette méthode
Moi dab, je liste les process en route et si il existe je bloque le giciel, mais ça fait un code de ouf
Là au moins....c'est succinct
Et c'est le premier de tes codes que je comprends