Einzelnen Beitrag anzeigen

Horst0815

Registriert seit: 23. Mai 2011
Ort: Görlitz
150 Beiträge
 
Delphi XE Starter
 
#1

Umgang mit PSafeArray

  Alt 14. Sep 2014, 20:11
versuche folgenden Code in Pascal umzusetzen

benötigte Typbilblotheken hab ich importiert

Microsoft IMAPI2 Base Functionality
Microsoft IMAPI2 File system Image Creator


Code:
' This script examines the burn device characteristics such as
' product ID, product revision level, feature set, and profiles.

' Copyright (C) Microsoft Corp. 2006

Option Explicit

' Constants
const IMAPI_FEATURE_PAGE_TYPE_DVD_DASH_WRITE = 47

WScript.Quit(Main)

Function Main
    Dim Index               ' Index to recording drive.
    Dim Recorder            ' Recorder object
    Dim Path                ' Directory of files to burn
    Dim Stream              ' Data stream for burning device
   
    Index = 1                ' Second drive on the system

    ' Create a DiscMaster2 object to connect to CD/DVD drives.
    Dim g_DiscMaster
    Set g_DiscMaster = WScript.CreateObject("IMAPI2.MsftDiscMaster2")

    ' Create a DiscRecorder object for the specified burning device.
    Dim uniqueId
    set recorder = WScript.CreateObject("IMAPI2.MsftDiscRecorder2")
    uniqueId = g_DiscMaster.Item(Index)
    recorder.InitializeDiscRecorder( uniqueId )

    ' *** - Formatting to display recorder info
    WScript.Echo "--------------------------------------------------"
    Wscript.Echo " ActiveRecorderId: " & recorder.ActiveDiscRecorder
    Wscript.Echo "       Vendor Id: " & recorder.VendorId
    Wscript.Echo "      Product Id: " & recorder.ProductId
    Wscript.Echo " Product Revision: " & recorder.ProductRevision
    Wscript.Echo "      VolumeName: " & recorder.VolumeName
    Wscript.Echo "  Can Load Media: " & recorder.DeviceCanLoadMedia
    Wscript.Echo "   Device Number: " & recorder.LegacyDeviceNumber
soweit so gut

Delphi-Quellcode:
Procedure TForm5.FormCreate(Sender: TObject);
Var
  Index, I, X: Integer;
  UniqueId, Temp: String;
  SupportedFeature: Integer;
  Safe, VolumePath, CurrentFeature: PSafeArray;
  MountPoint : Variant;
Begin
  Index := 0;
  UniqueId := DiscMaster2.Item[Index];
  DiscRecorder2.InitializeDiscRecorder(UniqueId);
  Memo1.Lines.Add('--------------------------------------------------');
  Memo1.Lines.Add(' ActiveRecorderId: ' + DiscRecorder2.ActiveDiscRecorder);
  Memo1.Lines.Add(' Vendor Id: ' + DiscRecorder2.VendorId);
  Memo1.Lines.Add(' Product Id: ' + DiscRecorder2.ProductId);
  Memo1.Lines.Add(' Product Revision: ' + DiscRecorder2.ProductRevision);
  Memo1.Lines.Add(' VolumeName: ' + DiscRecorder2.VolumeName);
  Memo1.Lines.Add(' Can Load Media: ' + BoolToStr(DiscRecorder2.DeviceCanLoadMedia,True));
    Memo1.Lines.Add(' Device Number: ' +
    Inttostr(DiscRecorder2.LegacyDeviceNumber));


DiscRecorder2.VolumePathNames ist ein PSafeArray

Code:
    Dim mountPoint
    For Each mountPoint In recorder.VolumePathNames
        WScript.Echo "    Mount Point: " & mountPoint
    Next



Delphi-Quellcode:
  for i := 0 to DiscRecorder2.VolumePathNames.cbElements -1 do
   begin
    Memo1.Lines.Add(' Mount Point: ' + PChar(DiscRecorder2.VolumePathNames[i].pvData)); //Array typ erforderlich
   end;
End;

Geändert von Horst0815 (15. Sep 2014 um 17:50 Uhr)
  Mit Zitat antworten Zitat