Live-Forum - Die aktuellen Beiträge
Anzeige
Archiv - Navigation
856to860
Aktuelles Verzeichnis
Verzeichnis Index
Übersicht Verzeichnisse
Vorheriger Thread
Rückwärts Blättern
Nächster Thread
Vorwärts blättern
Anzeige
HERBERS
Excel-Forum (Archiv)
20+ Jahre Excel-Kompetenz: Von Anwendern, für Anwender
856to860
856to860
Aktuelles Verzeichnis
Verzeichnis Index
Verzeichnis Index
Übersicht Verzeichnisse
Inhaltsverzeichnis

API-Zugriff

API-Zugriff
21.03.2007 08:39:41
Born
Hallo Forum,
ich möchte mit einem VBA-Script auf den laufenden Prozess von Word zugreifen. Auf den Excel-Prozess konnte ich mit

Private Sub test
Dim hProcess As Long
hProcess = GetCurrentProcess
End Sub
zugreifen. Welche API-Funktion muss ich statt GetCurrentProcess nutzen, um auf den Word-Prozess zuzugreifen?
Vielen Dank im Voraus,
M. Born

2
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
AW: API-Zugriff
21.03.2007 19:22:00
Horst
Hi,
was soll der Zugriff bewirken?
mfg Horst
AW: API-Zugriff
21.03.2007 23:09:00
Nepumuk
Hallo Host,
das frag ich mich auch, aber gehen tut's so:
' **********************************************************************
' Modul: Modul1 Typ: Allgemeines Modul
' **********************************************************************

Option Explicit

Private Declare Function CreateToolhelp32Snapshot Lib "kernel32.dll" ( _
    ByVal dwFlags As Long, _
    ByVal th32ProcessID As Long) As Long
Private Declare Function Process32First Lib "kernel32.dll" ( _
    ByVal hSnapshot As Long, _
    ByRef lppe As PROCESSENTRY32) As Long
Private Declare Function Process32Next Lib "kernel32.dll" ( _
    ByVal hSnapshot As Long, _
    ByRef lppe As PROCESSENTRY32) As Long
Private Declare Function CloseHandle Lib "kernel32.dll" ( _
    ByVal hObject As Long) As Long

Private Const TH32CS_SNAPPROCESS = &H2
Private Const MAX_PATH = 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

Public Sub Alle_Prozesse()
    Dim Snap As Long, Result As Long
    Dim Process As PROCESSENTRY32
    Snap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0)
    If Snap <> -1 Then
        Process.dwSize = Len(Process)
        Result = Process32First(Snap, Process)
        Do Until Result = 0
            If InStr(1, LCase$(Process.szExeFile), "winword.exe") Then
                MsgBox "Word läuft PID: " & CStr(Process.th32ProcessID)
                Exit Do
            End If
            Result = Process32Next(Snap, Process)
        Loop
    End If
    CloseHandle Snap
End Sub

Gruß
Nepumuk
Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige