1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: 282: 283: 284: 285: 286: 287: 288: 289: 290: 291: 292: 293: 294: 295: 296: 297: 298: 299: 300: 301: 302: 303: 304: 305: 306: 307: 308: 309: 310: 311: 312: 313: 314: 315: 316: 317: 318: 319: 320: 321: 322: 323: 324: 325: 326: 327: 328: 329: 330: 331: 332: 333: 334: 335: 336: 337: 338: 339: 340: 341: 342: 343: 344: 345: 346: 347: 348: 349: 350: 351: 352: 353: 354: 355: 356: 357: 358: 359: 360: 361: 362: 363: 364: 365: 366: 367: 368:
| unit UNeroAPI;
interface
uses Windows, Messages, SysUtils, Forms;
type NEROAPI_INIT_ERROR = ( NEROAPI_INIT_OK=0, NEROAPI_INIT_INVALID_ARGS, NEROAPI_INIT_UNSPECIFIED_ERROR, NEROAPI_INIT_INVALID_SERIAL_NUM, NEROAPI_INIT_DEMOVERSION_EXPIRED, NEROAPI_INIT_ALREADY_INITIALISED, NEROAPI_INIT_CANNOT_LOCK ); type NERO_MEDIUM_TYPE = ( NMT_UNKNOWN, NMT_CD_ROM, NMT_CD_RECORDABLE, NMT_CD_REWRITEABLE );
type NERO_MEDIA_TYPE = ( MEDIA_NONE = $00000000, MEDIA_CD = $00000001, MEDIA_DDCD = $00000002, MEDIA_DVD_M = $00000004, MEDIA_DVD_P = $00000008, MEDIA_DVD_ANY = MEDIA_DVD_M OR MEDIA_DVD_P, MEDIA_DVD_RAM = $00000010, MEDIA_ML = $00000020, MEDIA_MRW = $00000040, MEDIA_NO_CDR = $00000080, MEDIA_NO_CDRW = $00000100, MEDIA_CDRW = MEDIA_CD OR MEDIA_NO_CDR, MEDIA_CDR = MEDIA_CD OR MEDIA_NO_CDRW, MEDIA_DVD_ROM = $00000200, MEDIA_CDROM = $00000400, MEDIA_NO_DVD_M_RW = $00000800, MEDIA_NO_DVD_M_R = $00001000, MEDIA_NO_DVD_P_RW = $00002000, MEDIA_NO_DVD_P_R = $00004000, MEDIA_DVD_M_R = MEDIA_DVD_M OR MEDIA_NO_DVD_M_RW, MEDIA_DVD_M_RW = MEDIA_DVD_M OR MEDIA_NO_DVD_M_R, MEDIA_DVD_P_R = MEDIA_DVD_P OR MEDIA_NO_DVD_P_RW, MEDIA_DVD_P_RW = MEDIA_DVD_P OR MEDIA_NO_DVD_P_R, MEDIA_FPACKET = $00008000, MEDIA_VPACKET = $00010000, MEDIA_PACKETW = MEDIA_MRW OR MEDIA_FPACKET OR MEDIA_VPACKET, MEDIA_HDB = $00020000 );
type NERO_TRACK_TYPE = ( NTT_UNKNOWN, NTT_DATA, NTT_AUDIO );
type NEROAPI_OPTION = ( NEROAPI_OPTION_MSG_FILE_NAME, NEROAPI_OPTION_WRITE_BUFFER_SIZE );
type NEROAPI_SCSI_DEVTYPE = ( NEA_SCSI_DEVTYPE_UNKNOWN, NEA_SCSI_DEVTYPE_WORM, NEA_SCSI_DEVTYPE_CDROM, NEA_SCSI_DEVTYPE_UNSUPPORTED_WORM );
type NERO_MEDIA_SET = DWORD;
type NERO_CAPABILITIES = ( NSDI_ALLOWED = 1, NSDI_DAO = 2, NSDI_READ_CD_TEXT = 4, NSDI_VARIABLE_PAUSES_IN_TAO = 8, NSDI_DAO_WRITE_CD_TEXT = 16, NSDI_IMAGE_RECORDER =64, NSDI_UNDETECTED = 128, NSDI_IDE_BUS = 256, NSDI_SCSI_BUS = 512, NSDI_BUF_UNDERRUN_PROT = 1024, NSDI_RESERVED = 2048, NSDI_RESERVED2 = 4096, NSDI_ALLOW_CHANGE_BOOKTYPE = 8192 );
type NERO_CALLBACK = record ncCallbackFunction, ncUserData : Pointer; end;
type NERO_SETTINGS = record nstNeroFilesPath, nstVendor, nstSoftware, nstLanguageFile : PChar; nstIdle, nstUserDialog : NERO_CALLBACK; nstEnableOverburn : LongBool; nstOverburnSize : DWORD; end;
type NERO_TRACK_INFO = record ntiSessionNumber, ntiTrackNumber : DWORD; ntiTrackType : NERO_TRACK_TYPE; ntiTrackStartBlk, ntiTrackLengthInBlks: DWORD ; ntiArtist, ntiTitle : Array[0..64] of char; ntiISRC: Array[0..12] of char; ntiReserved: array [0..28] of DWORD; end;
type NERO_CD_INFO = record ncdiFreeCapacityInBlocks : DWORD; ncdiIsWriteable : LongBool; ncdiMediumType : NERO_MEDIUM_TYPE; ncdiArtist, ncdiTitle: array [0..64] of char; ncdiAvailableEraseModes, ncdiUnusedBlocks: DWORD; ncdiMediaType : NERO_MEDIA_TYPE ; ncdiReserved : array [0..28] of DWORD; ncdiNumTracks : DWORD; ncdiTrackInfos : array [0..0] of NERO_TRACK_INFO ; end;
type NERO_SPEED_INFOS = record nsiNumSupportedSpeeds, nsiBaseSpeedKBs : DWORD; nsiSupportedSpeedsKBs, nsiSupportedSpeeds : array[0..63] of DWORD; nsiReserved : array[0..31] of DWORD; end;
TProc = procedure; type NERO_SCSI_DEVICE_INFO = record nsdiDeviceName : array[0..63] of char; nsdiHostAdapterName : array[0..7] of char; nsdiHostAdapterNo, nsdiDeviceID : DWORD; nsdiDevType : NEROAPI_SCSI_DEVTYPE; nsdiDriveLetter : char; nsdiCapabilities : DWORD; nsdiReadSpeeds, nsdiWriteSpeeds : NERO_SPEED_INFOS; nsdiDriver : TProc; NsdiBufUnderrunProtName : Array[0..63] of Char; nsdiMandatoryBUPSpeed : DWORD; nsdiMediaSupport : NERO_MEDIA_SET; nsdiDriveBufferSize : DWORD; nsdiReserved : array[0..62] of DWORD; end;
type NERO_SCSI_DEVICE_INFOS = record nsdisNumDevInfos : DWORD; nsdisDevInfos : array[0..0] of NERO_SCSI_DEVICE_INFO; end;
type TNeroAPI = class private hndNero : THandle; public NeroSet : NERO_SETTINGS; constructor Create(Dir : String; var ErrMsg : String); destructor Destroy; override; function NeroInit(NeroSetting : NERO_SETTINGS) : String; procedure NeroClearErrors; procedure NeroDone; function GetAPIVersionEx(var MajHi, MajLo, MinHi, MinLo: Integer) : boolean; function NeroSetExpectedAPIVersionEx(MajHi, MajLo, MinHi, MinLo: Integer): Boolean; function NeroGetAvailableDrivesEx( MediaType: NERO_MEDIA_TYPE): NERO_SCSI_DEVICE_INFOS; published end;
implementation
uses Dialogs;
constructor TNeroApi.Create(Dir : String; var ErrMsg : String); begin inherited Create; SetCurrentDir(Dir); ErrMsg := ''; if FileExists('Neroapi.dll') then begin hndNero := LoadLibrary(PChar('Neroapi.dll')); if hndNero <> 0 then begin ErrMsg := NeroInit(NeroSet); end; end else errMsg := 'Error: Can''t find NeroAPI.dll'; end;
destructor TNeroAPI.Destroy; begin if hndNero <> 0 then begin NeroDone; FreeLibrary(hndNero); end; inherited Destroy; end;
function TNeroAPI.NeroInit(NeroSetting : NERO_SETTINGS) : String; Type TF = function(const NeroSettings: NERO_SETTINGS; const Ch : Pointer) : NEROAPI_INIT_ERROR; cdecl;
var Rez : NEROAPI_INIT_ERROR; Fun : TF; begin Result := ''; if hndNero <> 0 then begin @Fun := GetProcAddress(hndNero, 'NeroInit'); if @fun <> nil then try Rez := Fun(NeroSetting, nil); Application.ProcessMessages; if Rez <> (NEROAPI_INIT_OK) then begin case Rez of NEROAPI_INIT_INVALID_ARGS : Result := 'Error: NeroInit unsuccesful. Invalid arguments.'; NEROAPI_INIT_UNSPECIFIED_ERROR : Result := 'Error: NeroInit unsuccesful. Unspecified error.'; NEROAPI_INIT_INVALID_SERIAL_NUM : Result := 'Error: NeroInit unsuccesful. Invalid serial number.'; NEROAPI_INIT_DEMOVERSION_EXPIRED : Result := 'Error: NeroInit unsuccesful. Demoversion has expired.'; NEROAPI_INIT_ALREADY_INITIALISED : Result := 'Error: NeroInit unsuccesful. Nero allready initialized.'; NEROAPI_INIT_CANNOT_LOCK : Result := 'Error: NeroInit unsuccesful. Can not lock the drive.'; else Result := 'Error: NeroInit unsuccesful. Unknown error.'; end; hndNero := 0; end else Result := 'NeroInit OK'; except on E : Exception do Result := E.message; end; end else Result := 'Error: DLL not found!'; end;
procedure TNeroAPI.NeroClearErrors(); type TF = function : Integer; var fun : TF; begin if hndNero <> 0 then begin @Fun := GetProcAddress(hndNero, 'NeroClearErrors'); if @fun <> nil then Fun(); end; end;
procedure TNeroAPI.NeroDone(); type TF = Function : integer; var fun : TF; begin if hndNero <> 0 then begin @Fun := GetProcAddress(hndNero, 'NeroDone'); if @fun <> nil then Fun(); end; end;
function TNeroAPI.GetAPIVersionEx(var MajHi, MajLo, MinHi, MinLo : Integer) : Boolean; type TF = function (wMajHi, wMajLo, wMinHi, wMinLo, Res : Pointer) : Boolean; cdecl;
var Fun : TF; wMH, wML, wMiH, wMiL : word; begin Result := False; wMH := 0; wML := 0; wMiH := 0; wMiL := 0; if hndNero <> 0 then begin @Fun := GetProcAddress(hndNero, 'NeroGetAPIVersionEx'); if @fun <> nil then try Result := Fun(@wMH, @wML, @wMiH, @wMiL, nil); Application.ProcessMessages; except on E : Exception do MessageDlg(E.message, mtError, [mbOK], 0); end; end;
MajHi := wMH; MajLo := wML; MinHi := wMiH; MinLo := wMiL; end;
function TNeroAPI.NeroSetExpectedAPIVersionEx(MajHi, MajLo, MinHi, MinLo : Integer) : Boolean;
type TF = function (wMajHi, wMajLo, wMinHi, wMinLo : WORD; Res : Pointer) : Boolean; cdecl;
var Fun : TF; wMH, wML, wMiH, wMiL : word; begin Result := False; wMH := MajHi; wML := MajLo; wMiH := MinHi; wMiL := MinLo; if hndNero <> 0 then begin @Fun := GetProcAddress(hndNero, 'NeroSetExpectedAPIVersionEx'); if @fun <> nil then try Result := Fun(wMH, wML, wMiH, wMiL, nil); Application.ProcessMessages; except on E : Exception do MessageDlg(E.message, mtError, [mbOK], 0); end; end; end;
function TNeroAPI.NeroGetAvailableDrivesEx(MediaType : NERO_MEDIA_TYPE): NERO_SCSI_DEVICE_INFOS; type PDevInfos = ^NERO_SCSI_DEVICE_INFOS; TF = function (medType : NERO_MEDIA_TYPE; Reserved : Pointer) : PDevInfos ; cdecl;
var Fun : TF; vDevInfos : PDevInfos; begin if hndNero <> 0 then begin @Fun := GetProcAddress(hndNero, 'NeroGetAvailableDrivesEx'); if @fun <> nil then try vDevInfos := nil; vDevInfos := Fun(MediaType, nil); if vDevInfos = nil then Result.nsdisNumDevInfos := 0; Application.ProcessMessages; except on E : Exception do MessageDlg(E.message, mtError, [mbOK], 0); end; end end;
end. |