Comment savoir si Outlook est en cours d'exécution ?
2 réponses
Christine Pauli
Bonjour,
Exécutant un programme VBA dans Access, je voudrais savoir si Outlook est en
cours d'exécution ou non sur la machine où s'exécute mon programme VBA.
Quelqu'un pourrait-il m'indiquer la solution ?
Cette action est irreversible, confirmez la suppression du commentaire ?
Signaler le commentaire
Veuillez sélectionner un problème
Nudité
Violence
Harcèlement
Fraude
Vente illégale
Discours haineux
Terrorisme
Autre
Eric
Bonjour,
Cela est faisable en utilisant les APIs. Il existe peut être d'autres solutions. Le message est un peu long
1 - Copier ce code dans un module de portée globale nommé modProcess :
Option Compare Database Option Explicit
Const TH32CS_SNAPHEAPLIST = &H1 Const TH32CS_SNAPPROCESS = &H2 Const TH32CS_SNAPTHREAD = &H4 Const TH32CS_SNAPMODULE = &H8 Const TH32CS_SNAPALL = (TH32CS_SNAPHEAPLIST Or TH32CS_SNAPPROCESS Or TH32CS_SNAPTHREAD Or TH32CS_SNAPMODULE) Const TH32CS_INHERIT = &H80000000 Const MAX_PATH As Integer = 260 Private Type PROCESSENTRY32 dwSize As Long cntUsage As Long th32ProcessID As Long th32DefaultHeapID As Long th32ModuleID As Long cntThreads As Long th32ParentProcessID As Long pcPriClassBase As Long dwFlags As Long szExeFile As String * MAX_PATH End Type Private Declare Function CreateToolhelp32Snapshot Lib "Kernel32" _ (ByVal lFlags As Long, ByVal lProcessID As Long) As Long Private Declare Function Process32First Lib "Kernel32" _ (ByVal hSnapShot As Long, uProcess As PROCESSENTRY32) As Long Private Declare Function Process32Next Lib "Kernel32" _ (ByVal hSnapShot As Long, uProcess As PROCESSENTRY32) As Long Private Declare Sub CloseHandle Lib "Kernel32" (ByVal hPass As Long)
Public Function ProcessEnCours(NomProcess As String) As Boolean 'KPD-Team 2000 'URL: http://www.allapi.net/ 'E-Mail: ' *** quelques adaptations Dim hSnapShot As Long, uProcess As PROCESSENTRY32 Dim r As Long 'Takes a snapshot of the processes and the heaps, modules, 'and threads used by the processes hSnapShot = CreateToolhelp32Snapshot(TH32CS_SNAPALL, 0&) 'set the length of our ProcessEntry-type uProcess.dwSize = Len(uProcess) 'Retrieve information about the first process 'encountered in our system snapshot r = Process32First(hSnapShot, uProcess) Do While r If Left$(uProcess.szExeFile, IIf(InStr(1, uProcess.szExeFile, Chr$(0)) > 0, _ InStr(1, uProcess.szExeFile, Chr$(0)) - 1, 0)) = NomProcess Then ProcessEnCours = True Exit Do End If 'Retrieve information about the next process recorded in our system snapshot r = Process32Next(hSnapShot, uProcess) Loop 'close our snapshot handle CloseHandle hSnapShot End Function
2 - Appeler la fonction où le besoin apparait. Exemple sur l'évènement clic d'un bouton de commande, test de Thunderbird.exe :
Private Sub Commande0_Click() If ProcessEnCours("Thunderbird.exe") Then MsgBox "Thunderbird.exe en cours d'exécution", vbInformation End If End Sub
PS: Attention aux retours à la ligne intempestifs dûs au lecteur de News.
Bonjour,
Exécutant un programme VBA dans Access, je voudrais savoir si Outlook est en cours d'exécution ou non sur la machine où s'exécute mon programme VBA. Quelqu'un pourrait-il m'indiquer la solution ?
Merci d'avance.
Christine
-- A+ Eric http://www.mpfa.info/ Archives : http://groups.google.fr/group/microsoft.public.fr.access?hl=fr
Bonjour,
Cela est faisable en utilisant les APIs.
Il existe peut être d'autres solutions.
Le message est un peu long
1 - Copier ce code dans un module de portée globale nommé modProcess :
Option Compare Database
Option Explicit
Const TH32CS_SNAPHEAPLIST = &H1
Const TH32CS_SNAPPROCESS = &H2
Const TH32CS_SNAPTHREAD = &H4
Const TH32CS_SNAPMODULE = &H8
Const TH32CS_SNAPALL = (TH32CS_SNAPHEAPLIST Or TH32CS_SNAPPROCESS Or
TH32CS_SNAPTHREAD Or TH32CS_SNAPMODULE)
Const TH32CS_INHERIT = &H80000000
Const MAX_PATH As Integer = 260
Private Type PROCESSENTRY32
dwSize As Long
cntUsage As Long
th32ProcessID As Long
th32DefaultHeapID As Long
th32ModuleID As Long
cntThreads As Long
th32ParentProcessID As Long
pcPriClassBase As Long
dwFlags As Long
szExeFile As String * MAX_PATH
End Type
Private Declare Function CreateToolhelp32Snapshot Lib "Kernel32" _
(ByVal lFlags As Long, ByVal lProcessID As Long) As Long
Private Declare Function Process32First Lib "Kernel32" _
(ByVal hSnapShot As Long, uProcess As PROCESSENTRY32) As Long
Private Declare Function Process32Next Lib "Kernel32" _
(ByVal hSnapShot As Long, uProcess As PROCESSENTRY32) As Long
Private Declare Sub CloseHandle Lib "Kernel32" (ByVal hPass As Long)
Public Function ProcessEnCours(NomProcess As String) As Boolean
'KPD-Team 2000
'URL: http://www.allapi.net/
'E-Mail: KPDTeam@Allapi.net
' *** quelques adaptations
Dim hSnapShot As Long, uProcess As PROCESSENTRY32
Dim r As Long
'Takes a snapshot of the processes and the heaps, modules,
'and threads used by the processes
hSnapShot = CreateToolhelp32Snapshot(TH32CS_SNAPALL, 0&)
'set the length of our ProcessEntry-type
uProcess.dwSize = Len(uProcess)
'Retrieve information about the first process
'encountered in our system snapshot
r = Process32First(hSnapShot, uProcess)
Do While r
If Left$(uProcess.szExeFile, IIf(InStr(1, uProcess.szExeFile,
Chr$(0)) > 0, _
InStr(1, uProcess.szExeFile, Chr$(0)) - 1, 0)) = NomProcess Then
ProcessEnCours = True
Exit Do
End If
'Retrieve information about the next process recorded in our
system snapshot
r = Process32Next(hSnapShot, uProcess)
Loop
'close our snapshot handle
CloseHandle hSnapShot
End Function
2 - Appeler la fonction où le besoin apparait.
Exemple sur l'évènement clic d'un bouton de commande, test de
Thunderbird.exe :
Private Sub Commande0_Click()
If ProcessEnCours("Thunderbird.exe") Then
MsgBox "Thunderbird.exe en cours d'exécution", vbInformation
End If
End Sub
PS: Attention aux retours à la ligne intempestifs dûs au lecteur de News.
Bonjour,
Exécutant un programme VBA dans Access, je voudrais savoir si Outlook est en
cours d'exécution ou non sur la machine où s'exécute mon programme VBA.
Quelqu'un pourrait-il m'indiquer la solution ?
Merci d'avance.
Christine
--
A+
Eric
http://www.mpfa.info/
Archives : http://groups.google.fr/group/microsoft.public.fr.access?hl=fr
Cela est faisable en utilisant les APIs. Il existe peut être d'autres solutions. Le message est un peu long
1 - Copier ce code dans un module de portée globale nommé modProcess :
Option Compare Database Option Explicit
Const TH32CS_SNAPHEAPLIST = &H1 Const TH32CS_SNAPPROCESS = &H2 Const TH32CS_SNAPTHREAD = &H4 Const TH32CS_SNAPMODULE = &H8 Const TH32CS_SNAPALL = (TH32CS_SNAPHEAPLIST Or TH32CS_SNAPPROCESS Or TH32CS_SNAPTHREAD Or TH32CS_SNAPMODULE) Const TH32CS_INHERIT = &H80000000 Const MAX_PATH As Integer = 260 Private Type PROCESSENTRY32 dwSize As Long cntUsage As Long th32ProcessID As Long th32DefaultHeapID As Long th32ModuleID As Long cntThreads As Long th32ParentProcessID As Long pcPriClassBase As Long dwFlags As Long szExeFile As String * MAX_PATH End Type Private Declare Function CreateToolhelp32Snapshot Lib "Kernel32" _ (ByVal lFlags As Long, ByVal lProcessID As Long) As Long Private Declare Function Process32First Lib "Kernel32" _ (ByVal hSnapShot As Long, uProcess As PROCESSENTRY32) As Long Private Declare Function Process32Next Lib "Kernel32" _ (ByVal hSnapShot As Long, uProcess As PROCESSENTRY32) As Long Private Declare Sub CloseHandle Lib "Kernel32" (ByVal hPass As Long)
Public Function ProcessEnCours(NomProcess As String) As Boolean 'KPD-Team 2000 'URL: http://www.allapi.net/ 'E-Mail: ' *** quelques adaptations Dim hSnapShot As Long, uProcess As PROCESSENTRY32 Dim r As Long 'Takes a snapshot of the processes and the heaps, modules, 'and threads used by the processes hSnapShot = CreateToolhelp32Snapshot(TH32CS_SNAPALL, 0&) 'set the length of our ProcessEntry-type uProcess.dwSize = Len(uProcess) 'Retrieve information about the first process 'encountered in our system snapshot r = Process32First(hSnapShot, uProcess) Do While r If Left$(uProcess.szExeFile, IIf(InStr(1, uProcess.szExeFile, Chr$(0)) > 0, _ InStr(1, uProcess.szExeFile, Chr$(0)) - 1, 0)) = NomProcess Then ProcessEnCours = True Exit Do End If 'Retrieve information about the next process recorded in our system snapshot r = Process32Next(hSnapShot, uProcess) Loop 'close our snapshot handle CloseHandle hSnapShot End Function
2 - Appeler la fonction où le besoin apparait. Exemple sur l'évènement clic d'un bouton de commande, test de Thunderbird.exe :
Private Sub Commande0_Click() If ProcessEnCours("Thunderbird.exe") Then MsgBox "Thunderbird.exe en cours d'exécution", vbInformation End If End Sub
PS: Attention aux retours à la ligne intempestifs dûs au lecteur de News.
Bonjour,
Exécutant un programme VBA dans Access, je voudrais savoir si Outlook est en cours d'exécution ou non sur la machine où s'exécute mon programme VBA. Quelqu'un pourrait-il m'indiquer la solution ?
Merci d'avance.
Christine
-- A+ Eric http://www.mpfa.info/ Archives : http://groups.google.fr/group/microsoft.public.fr.access?hl=fr
Christine Pauli
Merci beaucoup Eric, cela fonctionne parfaitement bien, c'est tout à fait ce dont j'avais besoin. Bonne journée.
Christine.
"Eric" a écrit dans le message de news: %
Bonjour,
Cela est faisable en utilisant les APIs. Il existe peut être d'autres solutions. Le message est un peu long
1 - Copier ce code dans un module de portée globale nommé modProcess :
Option Compare Database Option Explicit
Const TH32CS_SNAPHEAPLIST = &H1 Const TH32CS_SNAPPROCESS = &H2 Const TH32CS_SNAPTHREAD = &H4 Const TH32CS_SNAPMODULE = &H8 Const TH32CS_SNAPALL = (TH32CS_SNAPHEAPLIST Or TH32CS_SNAPPROCESS Or TH32CS_SNAPTHREAD Or TH32CS_SNAPMODULE) Const TH32CS_INHERIT = &H80000000 Const MAX_PATH As Integer = 260 Private Type PROCESSENTRY32 dwSize As Long cntUsage As Long th32ProcessID As Long th32DefaultHeapID As Long th32ModuleID As Long cntThreads As Long th32ParentProcessID As Long pcPriClassBase As Long dwFlags As Long szExeFile As String * MAX_PATH End Type Private Declare Function CreateToolhelp32Snapshot Lib "Kernel32" _ (ByVal lFlags As Long, ByVal lProcessID As Long) As Long Private Declare Function Process32First Lib "Kernel32" _ (ByVal hSnapShot As Long, uProcess As PROCESSENTRY32) As Long Private Declare Function Process32Next Lib "Kernel32" _ (ByVal hSnapShot As Long, uProcess As PROCESSENTRY32) As Long Private Declare Sub CloseHandle Lib "Kernel32" (ByVal hPass As Long)
Public Function ProcessEnCours(NomProcess As String) As Boolean 'KPD-Team 2000 'URL: http://www.allapi.net/ 'E-Mail: ' *** quelques adaptations Dim hSnapShot As Long, uProcess As PROCESSENTRY32 Dim r As Long 'Takes a snapshot of the processes and the heaps, modules, 'and threads used by the processes hSnapShot = CreateToolhelp32Snapshot(TH32CS_SNAPALL, 0&) 'set the length of our ProcessEntry-type uProcess.dwSize = Len(uProcess) 'Retrieve information about the first process 'encountered in our system snapshot r = Process32First(hSnapShot, uProcess) Do While r If Left$(uProcess.szExeFile, IIf(InStr(1, uProcess.szExeFile, Chr$(0)) > 0, _ InStr(1, uProcess.szExeFile, Chr$(0)) - 1, 0)) = NomProcess Then ProcessEnCours = True Exit Do End If 'Retrieve information about the next process recorded in our system snapshot r = Process32Next(hSnapShot, uProcess) Loop 'close our snapshot handle CloseHandle hSnapShot End Function
2 - Appeler la fonction où le besoin apparait. Exemple sur l'évènement clic d'un bouton de commande, test de Thunderbird.exe :
Private Sub Commande0_Click() If ProcessEnCours("Thunderbird.exe") Then MsgBox "Thunderbird.exe en cours d'exécution", vbInformation End If End Sub
PS: Attention aux retours à la ligne intempestifs dûs au lecteur de News.
Bonjour,
Exécutant un programme VBA dans Access, je voudrais savoir si Outlook est en cours d'exécution ou non sur la machine où s'exécute mon programme VBA. Quelqu'un pourrait-il m'indiquer la solution ?
Merci d'avance.
Christine
-- A+ Eric http://www.mpfa.info/ Archives : http://groups.google.fr/group/microsoft.public.fr.access?hl=fr
Merci beaucoup Eric, cela fonctionne parfaitement bien, c'est tout à fait ce
dont j'avais besoin.
Bonne journée.
Christine.
"Eric" <f_framZZ@hotmail.com> a écrit dans le message de news:
%23U6Fqc37GHA.4476@TK2MSFTNGP04.phx.gbl...
Bonjour,
Cela est faisable en utilisant les APIs.
Il existe peut être d'autres solutions.
Le message est un peu long
1 - Copier ce code dans un module de portée globale nommé modProcess :
Option Compare Database
Option Explicit
Const TH32CS_SNAPHEAPLIST = &H1
Const TH32CS_SNAPPROCESS = &H2
Const TH32CS_SNAPTHREAD = &H4
Const TH32CS_SNAPMODULE = &H8
Const TH32CS_SNAPALL = (TH32CS_SNAPHEAPLIST Or TH32CS_SNAPPROCESS Or
TH32CS_SNAPTHREAD Or TH32CS_SNAPMODULE)
Const TH32CS_INHERIT = &H80000000
Const MAX_PATH As Integer = 260
Private Type PROCESSENTRY32
dwSize As Long
cntUsage As Long
th32ProcessID As Long
th32DefaultHeapID As Long
th32ModuleID As Long
cntThreads As Long
th32ParentProcessID As Long
pcPriClassBase As Long
dwFlags As Long
szExeFile As String * MAX_PATH
End Type
Private Declare Function CreateToolhelp32Snapshot Lib "Kernel32" _
(ByVal lFlags As Long, ByVal lProcessID As Long) As Long
Private Declare Function Process32First Lib "Kernel32" _
(ByVal hSnapShot As Long, uProcess As PROCESSENTRY32) As Long
Private Declare Function Process32Next Lib "Kernel32" _
(ByVal hSnapShot As Long, uProcess As PROCESSENTRY32) As Long
Private Declare Sub CloseHandle Lib "Kernel32" (ByVal hPass As Long)
Public Function ProcessEnCours(NomProcess As String) As Boolean
'KPD-Team 2000
'URL: http://www.allapi.net/
'E-Mail: KPDTeam@Allapi.net
' *** quelques adaptations
Dim hSnapShot As Long, uProcess As PROCESSENTRY32
Dim r As Long
'Takes a snapshot of the processes and the heaps, modules,
'and threads used by the processes
hSnapShot = CreateToolhelp32Snapshot(TH32CS_SNAPALL, 0&)
'set the length of our ProcessEntry-type
uProcess.dwSize = Len(uProcess)
'Retrieve information about the first process
'encountered in our system snapshot
r = Process32First(hSnapShot, uProcess)
Do While r
If Left$(uProcess.szExeFile, IIf(InStr(1, uProcess.szExeFile,
Chr$(0)) > 0, _
InStr(1, uProcess.szExeFile, Chr$(0)) - 1, 0)) = NomProcess Then
ProcessEnCours = True
Exit Do
End If
'Retrieve information about the next process recorded in our
system snapshot
r = Process32Next(hSnapShot, uProcess)
Loop
'close our snapshot handle
CloseHandle hSnapShot
End Function
2 - Appeler la fonction où le besoin apparait.
Exemple sur l'évènement clic d'un bouton de commande, test de
Thunderbird.exe :
Private Sub Commande0_Click()
If ProcessEnCours("Thunderbird.exe") Then
MsgBox "Thunderbird.exe en cours d'exécution", vbInformation
End If
End Sub
PS: Attention aux retours à la ligne intempestifs dûs au lecteur de News.
Bonjour,
Exécutant un programme VBA dans Access, je voudrais savoir si Outlook est
en
cours d'exécution ou non sur la machine où s'exécute mon programme VBA.
Quelqu'un pourrait-il m'indiquer la solution ?
Merci d'avance.
Christine
--
A+
Eric
http://www.mpfa.info/
Archives : http://groups.google.fr/group/microsoft.public.fr.access?hl=fr
Merci beaucoup Eric, cela fonctionne parfaitement bien, c'est tout à fait ce dont j'avais besoin. Bonne journée.
Christine.
"Eric" a écrit dans le message de news: %
Bonjour,
Cela est faisable en utilisant les APIs. Il existe peut être d'autres solutions. Le message est un peu long
1 - Copier ce code dans un module de portée globale nommé modProcess :
Option Compare Database Option Explicit
Const TH32CS_SNAPHEAPLIST = &H1 Const TH32CS_SNAPPROCESS = &H2 Const TH32CS_SNAPTHREAD = &H4 Const TH32CS_SNAPMODULE = &H8 Const TH32CS_SNAPALL = (TH32CS_SNAPHEAPLIST Or TH32CS_SNAPPROCESS Or TH32CS_SNAPTHREAD Or TH32CS_SNAPMODULE) Const TH32CS_INHERIT = &H80000000 Const MAX_PATH As Integer = 260 Private Type PROCESSENTRY32 dwSize As Long cntUsage As Long th32ProcessID As Long th32DefaultHeapID As Long th32ModuleID As Long cntThreads As Long th32ParentProcessID As Long pcPriClassBase As Long dwFlags As Long szExeFile As String * MAX_PATH End Type Private Declare Function CreateToolhelp32Snapshot Lib "Kernel32" _ (ByVal lFlags As Long, ByVal lProcessID As Long) As Long Private Declare Function Process32First Lib "Kernel32" _ (ByVal hSnapShot As Long, uProcess As PROCESSENTRY32) As Long Private Declare Function Process32Next Lib "Kernel32" _ (ByVal hSnapShot As Long, uProcess As PROCESSENTRY32) As Long Private Declare Sub CloseHandle Lib "Kernel32" (ByVal hPass As Long)
Public Function ProcessEnCours(NomProcess As String) As Boolean 'KPD-Team 2000 'URL: http://www.allapi.net/ 'E-Mail: ' *** quelques adaptations Dim hSnapShot As Long, uProcess As PROCESSENTRY32 Dim r As Long 'Takes a snapshot of the processes and the heaps, modules, 'and threads used by the processes hSnapShot = CreateToolhelp32Snapshot(TH32CS_SNAPALL, 0&) 'set the length of our ProcessEntry-type uProcess.dwSize = Len(uProcess) 'Retrieve information about the first process 'encountered in our system snapshot r = Process32First(hSnapShot, uProcess) Do While r If Left$(uProcess.szExeFile, IIf(InStr(1, uProcess.szExeFile, Chr$(0)) > 0, _ InStr(1, uProcess.szExeFile, Chr$(0)) - 1, 0)) = NomProcess Then ProcessEnCours = True Exit Do End If 'Retrieve information about the next process recorded in our system snapshot r = Process32Next(hSnapShot, uProcess) Loop 'close our snapshot handle CloseHandle hSnapShot End Function
2 - Appeler la fonction où le besoin apparait. Exemple sur l'évènement clic d'un bouton de commande, test de Thunderbird.exe :
Private Sub Commande0_Click() If ProcessEnCours("Thunderbird.exe") Then MsgBox "Thunderbird.exe en cours d'exécution", vbInformation End If End Sub
PS: Attention aux retours à la ligne intempestifs dûs au lecteur de News.
Bonjour,
Exécutant un programme VBA dans Access, je voudrais savoir si Outlook est en cours d'exécution ou non sur la machine où s'exécute mon programme VBA. Quelqu'un pourrait-il m'indiquer la solution ?
Merci d'avance.
Christine
-- A+ Eric http://www.mpfa.info/ Archives : http://groups.google.fr/group/microsoft.public.fr.access?hl=fr