Einzelnen Beitrag anzeigen

Benutzerbild von Gina
Gina

Registriert seit: 23. Dez 2004
Ort: Berlin
161 Beiträge
 
Delphi 6 Professional
 
#2

Re: DelphiNeroApi - Dateien übergeben

  Alt 13. Mär 2005, 17:16
So, hier mal meine aktuelle Test-Unit, vielleicht könnt ihr mir dann besser helfen

Delphi-Quellcode:
unit Unit2;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, NeroAPI, NeroUserDialog, NeroIsoTrack, dnapiComponents, StdCtrls, Registry;

type
  TForm1 = class(TForm)
    ListBoxBurn: TListBox;
    ListBoxSize: TListBox;
    Button1: TButton;
    Button2: TButton;
    dnapiSettings1: TdnapiSettings;
    procedure Button2Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    NeroIsoTrack: CNeroIsoTrack;
    RootIsoItem: PNeroIsoItem;
    NeroSettings: PNeroSettings;
    NeroDeviceHandle: NERO_DEVICEHANDLE;
    NeroProgress: NERO_PROGRESS;
    NeroCDInfo: PNeroCDInfo;
    NeroWriteCD: PNeroWriteCD;
    NeroDeviceInfos: PNeroSCSIDeviceInfos;
    NeroIsoItem: PNeroIsoItem;
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

function IdleCallback(pUserData: Pointer): Boolean; cdecl;
begin
  Application.ProcessMessages;

  Result := False;
end;

function ProgressCallback(pUserData: Pointer; dwProgressInPercent: DWORD): BOOL; cdecl;
begin
  Form1.ListBoxBurn.items.add(FormatFloat('000 ', dwProgressInPercent) + '%');

  Application.ProcessMessages;

  Result := IdleCallback(pUserData);
end;

function AbortedCallback(pUserData: Pointer): BOOL; cdecl;
begin
  Result := True; --> ist das richtig?
end;

procedure AddLogLine(pUserData: Pointer; _type: NERO_TEXT_TYPE; text: PChar); cdecl;
var
  Header: String;
begin
   case _type of
    NERO_TEXT_INFO: // informative text
    begin
      MessageDlg(text, mtInformation, [mbOK], 0);
    end;
    NERO_TEXT_STOP: // some operation stopped prematurely
    begin
      MessageDlg(text, mtError, [mbOK], 0);
      header := '# ';
    end;
    NERO_TEXT_EXCLAMATION: // important information
    begin
      MessageDlg(text, mtWarning, [mbOK], 0);
      header := '! ';
    end;
    NERO_TEXT_QUESTION: // a question which requires an answer
    begin
      MessageDlg(text, mtConfirmation, [mbOK], 0);
    end;
    NERO_TEXT_DRIVE:       // a message concerning a CD-ROM drive or recorder
    begin
      MessageDlg(text, mtInformation, [mbOK], 0);
    end;
  end;
end;

procedure SetPhaseCallback(pUserData: Pointer; text: PChar); cdecl;
begin
  ShowMessage(text);
end;

procedure DisableAbortCallback(pUserData: Pointer; abortEnabled: BOOL); cdecl;
begin
  if abortEnabled then
      ShowMessage('The current process cannot be interrupted')
   else
    ShowMessage('The process can be interrupted again');
end;

procedure SetMajorPhaseCallback(pUserData: Pointer; phase: NERO_MAJOR_PHASE; reserved: PVoid); cdecl;
begin
  case phase of
    NERO_PHASE_BUP_ACTIVATED: ShowMessage('BUP Activated');
    NERO_PHASE_CONTINUE_FORMATTING: ShowMessage('Continue Formating');
    NERO_PHASE_DONE_CACHE: ShowMessage('Done Caching');
    NERO_PHASE_DONE_SIMULATE: ShowMessage('Done Simulation');
    NERO_PHASE_DONE_SIMULATE_NOSPD: ShowMessage('Done Simulation - No SPD');
    NERO_PHASE_DONE_TEST: ShowMessage('Done Testing');
    NERO_PHASE_DONE_WRITE: ShowMessage('Done Writing');
    NERO_PHASE_DONE_WRITE_NOSPD: ShowMessage('Done Writing - No SPD');
    NERO_PHASE_DVDVIDEO_DETECTED: ShowMessage('DVD Video Detected');
    NERO_PHASE_DVDVIDEO_REALLOC_COMPLETED: ShowMessage('DVD Video Relloc Completed');
    NERO_PHASE_DVDVIDEO_REALLOC_FAILED: ShowMessage('DVD Video Realloc Failed');
    NERO_PHASE_DVDVIDEO_REALLOC_NOTNEEDED: ShowMessage('DVD Video Realloc Not Needed');
    NERO_PHASE_DVDVIDEO_REALLOC_STARTED: ShowMessage('DVD Video Relloc Started');
    NERO_PHASE_ENCODE_VIDEO: ShowMessage('Encoding Video');
    NERO_PHASE_FORMATTING_SUCCESSFUL: ShowMessage('Formating Successful');
    NERO_PHASE_SEAMLESSLINK_ACTIVATED: ShowMessage('Seamless Link Activated');
    NERO_PHASE_START_CACHE: ShowMessage('Caching Started');
    NERO_PHASE_START_SIMULATE: ShowMessage('Simulation Started');
    NERO_PHASE_START_SIMULATE_NOSPD: ShowMessage('Simulation Started - No SPD');
    NERO_PHASE_START_TEST: ShowMessage('Testing Started');
    NERO_PHASE_START_WRITE: ShowMessage('Writing Started');
    NERO_PHASE_START_WRITE_NOSPD: ShowMessage('Writing Started - No SPD');
    NERO_PHASE_UNSPECIFIED: ShowMessage('BUP Activated');
  end;
end;

procedure TForm1.Button2Click(Sender: TObject);
var
  flags: Cardinal;
begin
  Flags := NBF_SIMULATE + NBF_CLOSE_SESSION + NBF_BUF_UNDERRUN_PROT + NBF_DISABLE_EJECT; --> zum Test NBF_SIMULATE
  NeroIsoItem:=NeroCreateIsoItem();
  NeroIsoItem.fileName:='F:\test\test.rar';
  //insert item in to isotrack
  if Assigned(NeroWriteCD) then
     ReallocMem(NeroWriteCD, SizeOf(NERO_WRITE_CD))
  else
     NeroWriteCD :=AllocMem(SizeOf(NERO_WRITE_CD));
  NeroWriteCd.nwcdIsoTrack:=NeroCreateIsoTrackEx(NeroIsoItem,'',0) ;
  if Assigned(NeroDeviceHandle) then
     NeroCloseDevice(NeroDeviceHandle);

  NeroDeviceHandle := NeroOpenDevice(@NeroDeviceInfos.nsdisDevInfos[0]); --> Das dauert ein wenig. bei mir ist der Brenner Device 0.
  //then burn cd
  NeroBurn(NeroDeviceHandle, NERO_ISO_AUDIO_CD, NeroWriteCD, Flags, 8,@NeroProgress); --> leider brennt er nicht, bin mir nicht sicher, ob die speed stimmt
end;

procedure TForm1.FormCreate(Sender: TObject);
var
  lpdwSize, lpdwHandle: Cardinal;
  lpVerInfo, lpVS_FixedFileInfo: Pointer;
  Counter: Integer;
  nafi: PNeroAudioFormatInfo;
  ver1, ver2, ver3,ver4: WORD;
  initErr: NEROAPI_INIT_ERROR;
  Callback_1, Callback_2: NERO_CALLBACK;
  DeviceCount: Integer;
  Registry: TRegistry;
begin
  NeroIsoTrack := nil;
  RootIsoItem := nil;

  NeroDeviceHandle := nil;
  NeroDeviceInfos := nil;
  NeroCDInfo := nil;
  NeroWriteCD := nil;
  NeroSettings := nil;

  if (NeroAPIGlueConnect(nil)) then
    ShowMessage('Connected to NeroAPI !')
  else
  begin
    Showmessage('Cannot connect to NeroAPI !');
    exit;
  end;

   if (NeroGetAPIVersionEx(ver1, ver2, ver3, ver4, nil)) then
    Showmessage('Nero API version ' + IntToStr(ver1) + '.' +
      IntToStr(ver2) + '.' + IntToStr(ver3) + '.' + IntToStr(ver4))
  else
  begin
    Showmessage('Could not get NeroAPI version number !');
    exit;
  end;

  NeroSettings := AllocMem(sizeof(NERO_SETTINGS));


  Registry := TRegistry.Create(KEY_READ);
  Registry.RootKey := HKEY_LOCAL_MACHINE;
  Registry.OpenKey('SOFTWARE\Ahead\Shared', False);
  NeroSettings.nstNeroFilesPath := PAnsiChar(Registry.ReadString('NeroAPI'));
  Registry.Free;

  NeroSettings.nstVendor := '';
  NeroSettings.nstSoftware := 'ahead';
  NeroSettings.nstLanguageFile := 'nero.txt';

  Callback_1.ncCallbackFunction := @IdleCallback;
  Callback_1.ncUserData := nil;
  NeroSettings.nstIdle := Callback_1;

  NeroSettings.nstEnableOverburn := False;
  NeroSettings.nstOverburnSize := 0;

  initErr := NeroInit(@NeroSettings, nil);
  case (initErr) of
    NEROAPI_INIT_OK: begin end;
    NEROAPI_INIT_INVALID_ARGS:
      Showmessage('NeroInit() : invalid args');
    NEROAPI_INIT_INVALID_SERIAL_NUM:
      Showmessage('NeroInit() : invalid serial number');
    NEROAPI_INIT_DEMOVERSION_EXPIRED:
      Showmessage('NeroInit() : demo version has expired');
    NEROAPI_INIT_CANNOT_LOCK:
      Showmessage('NeroInit() : cannot lock');
    NEROAPI_INIT_UNSPECIFIED_ERROR:
      Showmessage('NeroInit() : unspecified error');
  else
    Showmessage('NeroInit() : unspecified error');
  end;

  if initErr <> NEROAPI_INIT_OK then
    Exit;

  NeroDeviceInfos := PNeroSCSIDeviceInfos(NeroGetAvailableDrivesEx(MEDIA_CD, nil));
   if not Assigned(NeroDeviceInfos) then
      ShowMessage('NeroGetAvailableDrives()');

  NeroProgress.npProgressCallback := ProgressCallback;
  NeroProgress.npAbortedCallback := AbortedCallback;
  NeroProgress.npAddLogLineCallback := AddLogLine;
  NeroProgress.npSetPhaseCallback := SetPhaseCallback;
  NeroProgress.npUserData := NeroSettings;
  NeroProgress.npDisableAbortCallback := DisableAbortCallback;
  NeroProgress.npSetMajorPhaseCallback := SetMajorPhaseCallback;

end;

end.
Also, irgendwie passiert nix. Er tut so, als wenn ich immer abbrechen würde. Meistens wirft er die CD aus, sagt mir aber nicht warum...
Hat jemand eine Idee?

Tausend Dank, Gina.
Mein Lieblings-Spiele-Laden in Berlin: www.cometgames-store.de

{KDT}
.
  Mit Zitat antworten Zitat