PDA

Vollständige Version anzeigen : Excel 32 Bit, Windows 64 Bit, Processe auslesen


lucio_07
25.08.2017, 11:25
Hallo,
ich komme einfach auf keine Lösung.

Meine Excel Anwendung (32 Bit) checkt im VBA welche Prozesse im Windows laufen.
Kann ich aus einer 32-Bit Anwendung heraus prüfen, welche Prozesse in W7 64 Bit laufen?

Vielen Dank im Voraus,

aloys78
25.08.2017, 11:48
Hallo Lucio,

ich habe Excel 2010 (32 Bit) und W7 (64 Bit) und da funktioniert folgender Code
Excel-Inside (http://www.excel-inside.de/vba-loesungen/sonstiges/987-windows-prozesse-auslesen-und-beenden)

Gruß
Aloys

lucio_07
25.08.2017, 11:53
Aloys,
danke für die schnelle Antwort.

Ich bekomme bei immer
Dim oServ As Object
'Set oServ = GetObject("winmgmts:")'

den Error: 'Automatisierungsfehler Ungültige Syntax'.
Nun dachte ich eben, .. wie gesagt ...

Gruß
lucio

lucio_07
25.08.2017, 12:46
Dann scheint das eine andere Ursache zu haben-

Danke.

Fennek11
25.08.2017, 13:18
Hallo,

eine relative einfache Methode, die tasks aufzulisten, geht in Word,

dim Tk as task
for each Tk in Application.Task
debug.print Tk
next Tk

Nepumuk
25.08.2017, 13:34
Hallo Lucio,

das liegt am Update KB4011051

Jetzt hast du zwei Möglichkeiten:

1. Das Update deinstallieren und sicherstellen das es nicht wieder automatisch installiert wird.

2. Auf API umstellen. Beispiel:

<div style="background-color:#FFFFFF; border-width:2px; border-style: groove; border-color:#ff9966; padding:4px;"><nobr><span style="font-family:Courier New,Arial; font-size:9pt ;" ><span style="color:#000080"; >Option</span> <span style="color:#000080"; >Explicit</span><br /><br /><span style="color:#000080"; >Private</span> <span style="color:#000080"; >Declare</span> <span style="color:#000080"; >Function</span> CreateToolhelp32Snapshot <span style="color:#000080"; >Lib</span> <span style="color:#800000"; >"kernel32.dll"</span> ( _<br />&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#000080"; >ByVal</span> dwFlags <span style="color:#000080"; >As</span> Long, _<br />&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#000080"; >ByVal</span> th32ProcessID <span style="color:#000080"; >As</span> <span style="color:#000080"; >Long</span>) <span style="color:#000080"; >As</span> <span style="color:#000080"; >Long</span><br /><span style="color:#000080"; >Private</span> <span style="color:#000080"; >Declare</span> <span style="color:#000080"; >Function</span> Process32First <span style="color:#000080"; >Lib</span> <span style="color:#800000"; >"kernel32.dll"</span> ( _<br />&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#000080"; >ByVal</span> hSnapshot <span style="color:#000080"; >As</span> Long, _<br />&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#000080"; >ByRef</span> lppe <span style="color:#000080"; >As</span> PROCESSENTRY32) <span style="color:#000080"; >As</span> <span style="color:#000080"; >Long</span><br /><span style="color:#000080"; >Private</span> <span style="color:#000080"; >Declare</span> <span style="color:#000080"; >Function</span> Process32Next <span style="color:#000080"; >Lib</span> <span style="color:#800000"; >"kernel32.dll"</span> ( _<br />&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#000080"; >ByVal</span> hSnapshot <span style="color:#000080"; >As</span> Long, _<br />&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#000080"; >ByRef</span> lppe <span style="color:#000080"; >As</span> PROCESSENTRY32) <span style="color:#000080"; >As</span> <span style="color:#000080"; >Long</span><br /><span style="color:#000080"; >Private</span> <span style="color:#000080"; >Declare</span> <span style="color:#000080"; >Function</span> CloseHandle <span style="color:#000080"; >Lib</span> <span style="color:#800000"; >"kernel32.dll"</span> ( _<br />&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#000080"; >ByVal</span> hObject <span style="color:#000080"; >As</span> <span style="color:#000080"; >Long</span>) <span style="color:#000080"; >As</span> <span style="color:#000080"; >Long</span><br /><span style="color:#000080"; >Private</span> <span style="color:#000080"; >Declare</span> <span style="color:#000080"; >Function</span> TerminateProcess <span style="color:#000080"; >Lib</span> <span style="color:#800000"; >"kernel32.dll"</span> ( _<br />&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#000080"; >ByVal</span> hProcess <span style="color:#000080"; >As</span> Long, _<br />&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#000080"; >ByVal</span> uExitCode <span style="color:#000080"; >As</span> <span style="color:#000080"; >Long</span>) <span style="color:#000080"; >As</span> <span style="color:#000080"; >Long</span><br /><span style="color:#000080"; >Private</span> <span style="color:#000080"; >Declare</span> <span style="color:#000080"; >Function</span> OpenProcess <span style="color:#000080"; >Lib</span> <span style="color:#800000"; >"kernel32.dll"</span> ( _<br />&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#000080"; >ByVal</span> dwDesiredAccess <span style="color:#000080"; >As</span> Long, _<br />&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#000080"; >ByVal</span> bInheritHandle <span style="color:#000080"; >As</span> Long, _<br />&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#000080"; >ByVal</span> dwProcessId <span style="color:#000080"; >As</span> <span style="color:#000080"; >Long</span>) <span style="color:#000080"; >As</span> <span style="color:#000080"; >Long</span><br /><br /><span style="color:#000080"; >Private</span> <span style="color:#000080"; >Const</span> TH32CS_SNAPPROCESS <span style="color:#000080"; >As</span> <span style="color:#000080"; >Long</span> = &H2<br /><span style="color:#000080"; >Private</span> <span style="color:#000080"; >Const</span> MAX_PATH <span style="color:#000080"; >As</span> <span style="color:#000080"; >Long</span> = 260<br /><span style="color:#000080"; >Private</span> <span style="color:#000080"; >Const</span> PROCESS_VM_READ <span style="color:#000080"; >As</span> <span style="color:#000080"; >Long</span> = &H10<br /><br /><span style="color:#000080"; >Private</span> <span style="color:#000080"; >Type</span> PROCESSENTRY32<br />&nbsp;&nbsp;&nbsp;&nbsp;dwSize <span style="color:#000080"; >As</span> <span style="color:#000080"; >Long</span><br />&nbsp;&nbsp;&nbsp;&nbsp;cntUsage <span style="color:#000080"; >As</span> <span style="color:#000080"; >Long</span><br />&nbsp;&nbsp;&nbsp;&nbsp;th32ProcessID <span style="color:#000080"; >As</span> <span style="color:#000080"; >Long</span><br />&nbsp;&nbsp;&nbsp;&nbsp;th32DefaultHeapID <span style="color:#000080"; >As</span> <span style="color:#000080"; >Long</span><br />&nbsp;&nbsp;&nbsp;&nbsp;th32ModuleID <span style="color:#000080"; >As</span> <span style="color:#000080"; >Long</span><br />&nbsp;&nbsp;&nbsp;&nbsp;cntThreads <span style="color:#000080"; >As</span> <span style="color:#000080"; >Long</span><br />&nbsp;&nbsp;&nbsp;&nbsp;th32ParentProcessID <span style="color:#000080"; >As</span> <span style="color:#000080"; >Long</span><br />&nbsp;&nbsp;&nbsp;&nbsp;pcPriClassBase <span style="color:#000080"; >As</span> <span style="color:#000080"; >Long</span><br />&nbsp;&nbsp;&nbsp;&nbsp;dwFlags <span style="color:#000080"; >As</span> <span style="color:#000080"; >Long</span><br />&nbsp;&nbsp;&nbsp;&nbsp;szExeFile <span style="color:#000080"; >As</span> <span style="color:#000080"; >String</span> * MAX_PATH<br /><span style="color:#000080"; >End</span> <span style="color:#000080"; >Type</span><br /><br /><b><span style="color:#000080"; >Public</span> <span style="color:#000080"; >Sub</span> Prozesslist()</b><br />&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#000080"; >Dim</span> lngSnap <span style="color:#000080"; >As</span> Long, udtProcess <span style="color:#000080"; >As</span> PROCESSENTRY32, lngResult <span style="color:#000080"; >As</span> Long, lngRow<br />&nbsp;&nbsp;&nbsp;&nbsp;lngSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0)<br />&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#000080"; >If</span> lngSnap &lt;&gt; -1 <span style="color:#000080"; >Then</span><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;udtProcess.dwSize = Len(udtProcess)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;lngResult = Process32First(lngSnap, udtProcess)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#000080"; >Do</span> <span style="color:#000080"; >Until</span> lngResult = 0<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;lngRow = lngRow + 1<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Cells(lngRow, 1).Value = Left$(udtProcess.szExeFile, _<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;InStr(1, udtProcess.szExeFile, vbNullChar) - 1)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;udtProcess.szExeFile = vbNullString<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;lngResult = Process32Next(lngSnap, udtProcess)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#000080"; >Loop</span><br />&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#000080"; >End</span> <span style="color:#000080"; >If</span><br />&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#000080"; >Call</span> CloseHandle(lngSnap)<br /><b><span style="color:#000080"; >End</span> <span style="color:#000080"; >Sub</span></b><br /></span></nobr></div>

lucio_07
01.09.2017, 12:37
Das ist SUPER!!
Vielen Dank

Gruss
lucio