Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Win32/Win64 API (native code) (https://www.delphipraxis.net/17-win32-win64-api-native-code/)
-   -   Umgang mit PSafeArray (https://www.delphipraxis.net/181879-umgang-mit-psafearray.html)

Horst0815 14. Sep 2014 19:11

Umgang mit PSafeArray
 
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;

TiGü 15. Sep 2014 08:51

AW: Umgang mit PSafeArray
 
Wenn man mit gedrückter Strg-Taste mit der linken Maustaste auf ".pvData" klickt, wo landet man da und was steht da genau?

Horst0815 15. Sep 2014 16:50

AW: Umgang mit PSafeArray
 
Liste der Anhänge anzeigen (Anzahl: 1)
na PSafeArray is so:

Delphi-Quellcode:
 

 PSafeArray = ^TSafeArray;
  {$EXTERNALSYM tagSAFEARRAY}
  tagSAFEARRAY = record
    cDims: Word;
    fFeatures: Word;
    cbElements: LongWord;
    cLocks: LongWord;
    pvData: Pointer;
    rgsabound: array[0..0] of TSafeArrayBound;
  end;
  TSafeArray = tagSAFEARRAY;
definiert


Kann ja nicht gehen heist ja nicht umsonst PSafeArray


aber

Delphi-Quellcode:
 
  CopyMemory(@Safe,DiscRecorder2.VolumePathNames,DiscRecorder2.VolumePathNames.CbElements);
 For I := 0 To DiscRecorder2.VolumePathNames.CbElements - 1 Do
  Begin

    Memo1.Lines.Add('      Mount Point: ' + (Safe[I]));
  End;
führt zu
[dcc32 Fehler] Main.pas(115): E2149 Klasse besitzt keine Standardeigenschaft

TiGü 16. Sep 2014 12:36

AW: Umgang mit PSafeArray
 
Dir ist schon klar das PSafeArray ein Zeiger auf ein record/struct ist und kein Array?
Delphi-Quellcode:
  PSafeArray = ^TSafeArray;
  {$EXTERNALSYM tagSAFEARRAY}
  tagSAFEARRAY = record
    cDims: Word;
    fFeatures: Word;
    cbElements: LongWord;
    cLocks: LongWord;
    pvData: Pointer;
    rgsabound: array[0..0] of TSafeArrayBound;
  end;
  TSafeArray = tagSAFEARRAY;
  {$EXTERNALSYM SAFEARRAY}
  SAFEARRAY = TSafeArray;
Vielleicht hilft dir das auch weiter?
http://blog.virtec.org/2008/07/the-m...of-psafearray/


Alle Zeitangaben in WEZ +1. Es ist jetzt 20:27 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