AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

VBS (For Each xxx in xxxx) -> Delphi

Ein Thema von Piro · begonnen am 24. Nov 2006 · letzter Beitrag vom 25. Nov 2006
Antwort Antwort
Benutzerbild von Piro
Piro

Registriert seit: 14. Jul 2003
Ort: Flintbek
810 Beiträge
 
Delphi XE2 Professional
 
#1

VBS (For Each xxx in xxxx) -> Delphi

  Alt 24. Nov 2006, 21:07
Hi Leute,

ich hoffe einer kann mir den Code von VBS in Delphi übersetzen. Habe schon etwas übersetzt. Ich komme bloss mit der For Each xxx in xxxx nicht weiter. Was muss ich da nehmen.

Code:
' Original VBS Code

sActionName="Hardware Inventory Collection Cycle"

Dim oCPAppletMgr
Set oCPAppletMgr = CreateObject("CPApplet.CPAppletMgr")

Dim oClientActions
Set oClientActions = oCPAppletMgr.GetClientActions()

Dim oClientAction
For Each oClientAction In oClientActions
     If oClientAction.Name = sActionName Then
        oClientAction.PerformAction
     End If
Next
Mein Delphi Code
Delphi-Quellcode:
procedure vbscript;
var
  sActionName : string;
  oCPAppletMgr, oClientActions, oClientAction : Variant;
begin
 sActionName := 'Hardware Inventory Collection Cycle';

 oCPAppletMgr := CreateOleObject('CPApplet.CPAppletMgr');
 oClientActions := oCPAppletMgr.GetClientActions();

 for oClientAction in oClientActions do
 begin
   If oClientAction.Name = sActionName Then
        oClientAction.PerformAction;
 end;
end;
Denn letzten Teil mit der For-Schleife bekomme ich leider nicht hin. Wäre voll gut wenn mir einer helfen könnte.

Gruß, Sven
  Mit Zitat antworten Zitat
Benutzerbild von Bernhard Geyer
Bernhard Geyer

Registriert seit: 13. Aug 2002
17.171 Beiträge
 
Delphi 10.4 Sydney
 
#2

Re: VBS (For Each xxx in xxxx) -> Delphi

  Alt 24. Nov 2006, 21:24
Blinder versuch:

Delphi-Quellcode:
for i := 0 to oClientActions.length - 1 do
begin
  oClientAction := oClientActions.Items[i];
  ...

end;
Windows Vista - Eine neue Erfahrung in Fehlern.
  Mit Zitat antworten Zitat
Benutzerbild von Piro
Piro

Registriert seit: 14. Jul 2003
Ort: Flintbek
810 Beiträge
 
Delphi XE2 Professional
 
#3

Re: VBS (For Each xxx in xxxx) -> Delphi

  Alt 24. Nov 2006, 21:56
Danke für deine schnelle Antwort.

Aber ich bräuchte etwas sicheres. Kann schlecht Testen.

Danke, Sven
  Mit Zitat antworten Zitat
Benutzerbild von Bernhard Geyer
Bernhard Geyer

Registriert seit: 13. Aug 2002
17.171 Beiträge
 
Delphi 10.4 Sydney
 
#4

Re: VBS (For Each xxx in xxxx) -> Delphi

  Alt 24. Nov 2006, 22:07
Zitat von daywalker299:
Aber ich bräuchte etwas sicheres. Kann schlecht Testen.
Kann auch schlecht testen. Habe diesen COM-Control nicht auf meinem Rechner.
Windows Vista - Eine neue Erfahrung in Fehlern.
  Mit Zitat antworten Zitat
Benutzerbild von Piro
Piro

Registriert seit: 14. Jul 2003
Ort: Flintbek
810 Beiträge
 
Delphi XE2 Professional
 
#5

Re: VBS (For Each xxx in xxxx) -> Delphi

  Alt 24. Nov 2006, 22:32
Habe gerade mal getestet.

Kommt mit einem Fehler:
Zitat:
"Exception der Klasse EOleSysError mit der Meldung "Invalid number of parameters"
  Mit Zitat antworten Zitat
Jennes

Registriert seit: 7. Dez 2005
Ort: Leipzig
26 Beiträge
 
Delphi 2005 Professional
 
#6

Re: VBS (For Each xxx in xxxx) -> Delphi

  Alt 25. Nov 2006, 09:24
wenn Du die Struktur des Objekts nicht hast wird's schwierig, evtl. gibt's ja auch ein oClientActions.Count oder oClientActions.Items.Count
Versuch macht kluch in diesem Fall
  Mit Zitat antworten Zitat
Benutzerbild von Piro
Piro

Registriert seit: 14. Jul 2003
Ort: Flintbek
810 Beiträge
 
Delphi XE2 Professional
 
#7

Re: VBS (For Each xxx in xxxx) -> Delphi

  Alt 25. Nov 2006, 09:59
Ich weiß nicht, wie die Struktur ist aber ich weiß was rauskommen muss.

Folgendes liefert das VBS Script, wenn man ein "MsgBox oClientAction.Name" einbaut.
Zitat:
Software Inventory Collection Cycle
MSI Product Source Update Cycle
Hardware Inventory Collection Cycle
Standard File Collection Cycle
Discovery Data Collection Cycle
Request & Evaluate User Policy
Request & Evaluate Machine Policy
Software Metering Usage Report Cycle
oClientActions.Count / oClientActions.Items.Count / oClientActions.length funktioniert leider nicht.

Ich hoffe mir kann noch einer sagen, wie ich das hinbekomme.
  Mit Zitat antworten Zitat
Benutzerbild von Piro
Piro

Registriert seit: 14. Jul 2003
Ort: Flintbek
810 Beiträge
 
Delphi XE2 Professional
 
#8

Re: VBS (For Each xxx in xxxx) -> Delphi

  Alt 25. Nov 2006, 10:30
Ich bin jetzt einen kleinen Schritt weiter. Es lag nicht unbedingt an der For-Schleife. Davor war auch schon ein Fehler.

Delphi-Quellcode:
procedure vbscript;
var
  sActionName : string;
  oCPAppletMgr, oClientActions, oClientAction : Variant;
  i: Integer;
begin
 sActionName := 'Hardware Inventory Collection Cycle';
 oCPAppletMgr := CreateOleObject('CPApplet.CPAppletMgr');
 oClientActions := oCPAppletMgr.GetClientActions;

 ShowMessage(IntToStr(oClientActions.Count)); //Liefert 8

 for i:=0 to oClientActions.Count do
   If oClientAction = sActionName Then // Hier ist noch ein Fehler : oCLientAction ist leer
        oClientAction.PerformAction;
end;
Wie kann ich jetzt oClientAction die Elemente von oClientActions zuordnen? Array?
  Mit Zitat antworten Zitat
Benutzerbild von thkerkmann
thkerkmann

Registriert seit: 7. Jan 2006
Ort: Pulheim Brauweiler
464 Beiträge
 
Delphi 2010 Professional
 
#9

Re: VBS (For Each xxx in xxxx) -> Delphi

  Alt 25. Nov 2006, 11:53
Hat Bernhard doch schon geschrieben
Delphi-Quellcode:
for ....
begin
  oClientAction := oClientActions.Items[i];
  ...
Gruss
Thomas Kerkmann
Ich hab noch einen Koffer in Borland.
http://thomaskerkmann.wordpress.com/
  Mit Zitat antworten Zitat
Benutzerbild von Piro
Piro

Registriert seit: 14. Jul 2003
Ort: Flintbek
810 Beiträge
 
Delphi XE2 Professional
 
#10

Re: VBS (For Each xxx in xxxx) -> Delphi

  Alt 25. Nov 2006, 18:10
Danke an alle, irgendwie war ich blind.

Hier der endgültige Code:
Delphi-Quellcode:
procedure vbscript;
var
  oCPAppletMgr, oClientActions, oClientAction : OleVariant;
  i : Integer;
  sActionName : String;
begin
 sActionName := 'Hardware Inventory Collection Cycle';
 oCPAppletMgr := CreateOleObject('CPApplet.CPAppletMgr');
 oClientActions := oCPAppletMgr.GetClientActions;

 for i:=1 to oClientActions.Count do
 begin
   oClientAction := oClientActions.Item[i];
   //ShowMessage(oClientAction.Name);
   If oClientAction.Name = sActionName Then
        oClientAction.PerformAction;
 end;
end;
Schönen Samstag-Abend noch.
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 01:02 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz