![]() |
[WMI] Prozesse remote auflisten
Liste der Anhänge anzeigen (Anzahl: 1)
Ich benutze folgenden Code, um mir die Prozesses des Computers aufzulisten per WMI:
Delphi-Quellcode:
Folgende Probleme:
uses
WbemScripting_TLB, ActiveX; type TProcesInformation = packed record Name: string; Path: string; ProcID: DWORD; ParentProcID: DWORD; SessionID: DWORD; ThreadCount: DWORD; Priority: DWORD; end; type TPIArray = array of TProcesInformation; const WMI_HOST_COMPUTER = '.'; WMI_SYSTEM_NAMESPACE = 'root\CIMV2'; WMI_CLASS_NIC = 'Win32_Process'; WMI_ATTRIB_CAPTION = 'Name'; WMI_ATTRIB_PATH = 'ExecutablePath'; WMI_ATTRIB_PROCID = 'ProcessID'; WMI_ATTRIB_PARENT_PROCID = 'ParentProcessId'; WMI_ATTRIB_SESSIONID = 'SessionID'; WMI_ATTRIB_THREAD_CNT = 'ThreadCount'; WMI_ATTRIB_PRIORITY = 'Priority'; function WMIEnumProcesses(Computer, User, Password: String): TPIArray; var Locator : ISWbemLocator; Services : ISWbemServices; ObjectDefinition: ISWbemObject; ObjectSet : SWbemObjectSet; ObjectInstances: IEnumVariant; WMIObject : ISWbemObject; PropertySet : ISWbemPropertySet; WMIProperty : ISWbemProperty; TempObj : OleVariant; ObjValue : Cardinal; i : Integer; resourcestring rsWMIError = 'WMI-Fehler'; begin i := 0; Locator := CoSWbemLocator.CreateRemote(Computer); try try Services := Locator.ConnectServer(Computer, WMI_SYSTEM_NAMESPACE, User, Password, '', '', 0, nil); if Services <> nil then begin ObjectDefinition := Services.Get(WMI_CLASS_NIC, wbemFlagUseAmendedQualifiers, nil); ObjectSet := ObjectDefinition.Instances_(0, nil); ObjectInstances := (ObjectSet._NewEnum) as IEnumVariant; while (ObjectInstances.Next(1, TempObj, ObjValue) = S_OK) do begin WMIObject := IUnknown(TempObj) as SWBemObject; PropertySet := WMIObject.Properties_; setlength(result, length(result) + 1); WMIProperty := PropertySet.Item(WMI_ATTRIB_CAPTION, 0); if not VarIsNull(WMIProperty.Get_Value) then result[i].Name := WMIProperty.Get_Value; WMIProperty := PropertySet.Item(WMI_ATTRIB_PATH, 0); if not VarIsNull(WMIProperty.Get_Value) then result[i].Path := WMIProperty.Get_Value; WMIProperty := PropertySet.Item(WMI_ATTRIB_PROCID, 0); if not VarIsNull(WMIProperty.Get_Value) then result[i].ProcID := WMIProperty.Get_Value; WMIProperty := PropertySet.Item(WMI_ATTRIB_PARENT_PROCID, 0); if not VarIsNull(WMIProperty.Get_Value) then result[i].ParentProcID := WMIProperty.Get_Value; WMIProperty := PropertySet.Item(WMI_ATTRIB_SESSIONID, 0); if not VarIsNull(WMIProperty.Get_Value) then result[i].SessionID := WMIProperty.Get_Value; WMIProperty := PropertySet.Item(WMI_ATTRIB_THREAD_CNT, 0); if not VarIsNull(WMIProperty.Get_Value) then result[i].ThreadCount := WMIProperty.Get_Value; WMIProperty := PropertySet.Item(WMI_ATTRIB_PRIORITY, 0); if not VarIsNull(WMIProperty.Get_Value) then result[i].Priority := WMIProperty.Get_Value; Inc(i); end; end; finally Locator := nil; Services := nil; end; except on e: Exception do raise e.Create(e.message); end; end;
|
Re: [WMI] Prozesse remote auflisten
Ich schau mir das mal an sobald ich wieder zuhause bin. Sollte kein Problem darstellen. In WMI bin ich recht fit.
Ich kann Dir aber auch mal (sofern ich das noch finde) eine komplette WMI-Beispielapplikation schicken, die auch Remote funktioniert. Mach ich heute Abend. Wenn nicht, erinnere mich bitte nochmal per PN dran. Ich muss jetzt blöderweise schnell ins Kaufland um die Ecke um noch ein paar DSL-Anschlüsse zu verkaufen ;-) |
Re: [WMI] Prozesse remote auflisten
Hi,
wenn ich "localhost" mit meinem Username und PW eintrage, erhalte ich in der ListView nur den Text "Klasse nicht registriert" :? Ich hab WinXP Prof. SP2 mfG mirage228 |
Alle Zeitangaben in WEZ +1. Es ist jetzt 09:59 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz