here is an include file for IMAPIv2 in case you perfer to use it and below that is our refined code using the imapi2_include.pbi file. Some of the things in the include are not used in the code, this is just the overall include i'm using as I develop this a little more.
(the .pbi includes most of what is needed for the basics for IMAPIv2. Some of the things i'm still working on)
Code: Select all
; imapi2_include.pbi v 1.6 - 26 Jan 2008
; for PureBasic using version 4.10
; by SFSxOI
; On XP sp2 you have To install KB932716 (Image Mastering API v2.0) first
;*************************************************************************************************
; credits: 
; folder To iso created by bingo - http://www.purebasic.fr/english/viewtopic.php?t=29757
; traumatic and Shardik for SAFEARRAY help: http://www.purebasic.fr/english/viewtopic.php?t=30583
; Microsoft
;*************************************************************************************************
; implementation notes:
; As noted with in-code-remarks
; ##########################################
; #         Imports                        #
; ##########################################
Import "shlwapi.lib" 
SHCreateStreamOnFileEx(pszFile.p-unicode,grfMode.l,dwAttributes.l,fCreate.b,pstmTemplate.l,ppstm.l); 
EndImport
; ##########################################
; #         Constants and Enumerations     #
; ##########################################
;////////////Constants////////////////
#STGM_SHARE_DENY_NONE = 64
#STGM_READ = 0
#STGM_WRITE = 1 
#STGM_CREATE = 4096 
#STATFLAG_NONAME = 0
;Number of bytes in a sector.
#IMAPI_SECTOR_SIZE = 2048
;Base rate of speed that a CD spins, measured in sectors per second.
#IMAPI_SECTORS_PER_SECOND_AT_1X_CD = 75
;Base
#IMAPI_SECTORS_PER_SECOND_AT_1X_DVD = 680
;///////////Enumerations/////////////
Enumeration ; _STORAGE_BUS_TYPE
  #BusTypeUnknown
  #BusTypeScsi
  #BusTypeAtapi
  #BusTypeAta
  #BusType1394
  #BusTypeSsa
  #BusTypeFibre
  #BusTypeUsb
  #BusTypeRAID
  #BusTypeiScsi
  #BusTypeSas
  #BusTypeSata
  #BusTypeSd
  #BusTypeMmc
  #BusTypeMax
  #BusTypeMaxReserved = 127
EndEnumeration
Enumeration ; _IMAPI_FORMAT2_DATA_WRITE_ACTION
  #IMAPI_FORMAT2_DATA_WRITE_ACTION_VALIDATING_MEDIA=0
  #IMAPI_FORMAT2_DATA_WRITE_ACTION_FORMATTING_MEDIA=1
  #IMAPI_FORMAT2_DATA_WRITE_ACTION_INITIALIZING_HARDWARE=2
  #IMAPI_FORMAT2_DATA_WRITE_ACTION_CALIBRATING_POWER=3
  #IMAPI_FORMAT2_DATA_WRITE_ACTION_WRITING_DATA=4
  #IMAPI_FORMAT2_DATA_WRITE_ACTION_FINALIZATION=5
  #IMAPI_FORMAT2_DATA_WRITE_ACTION_COMPLETED=6
EndEnumeration
Enumeration ; _IMAPI_FORMAT2_TAO_WRITE_ACTION
  #IMAPI_FORMAT2_TAO_WRITE_ACTION_UNKNOWN=0
  #IMAPI_FORMAT2_TAO_WRITE_ACTION_PREPARING=1
  #IMAPI_FORMAT2_TAO_WRITE_ACTION_WRITING=2
  #IMAPI_FORMAT2_TAO_WRITE_ACTION_FINISHING=3
EndEnumeration
Enumeration ; _IMAPI_FORMAT2_RAW_CD_WRITE_ACTION
  #IMAPI_FORMAT2_RAW_CD_WRITE_ACTION_UNKNOWN=0
  #IMAPI_FORMAT2_RAW_CD_WRITE_ACTION_PREPARING=1
  #IMAPI_FORMAT2_RAW_CD_WRITE_ACTION_WRITING=2
  #IMAPI_FORMAT2_RAW_CD_WRITE_ACTION_FINISHING=3
EndEnumeration
Enumeration ; _IMAPI_MEDIA_PHYSICAL_TYPE
  #IMAPI_MEDIA_TYPE_UNKNOWN=0
  #IMAPI_MEDIA_TYPE_CDROM=1
  #IMAPI_MEDIA_TYPE_CDR=2
  #IMAPI_MEDIA_TYPE_CDRW=3
  #IMAPI_MEDIA_TYPE_DVDROM=4
  #IMAPI_MEDIA_TYPE_DVDRAM=5
  #IMAPI_MEDIA_TYPE_DVDPLUSR=6
  #IMAPI_MEDIA_TYPE_DVDPLUSRW=7
  #IMAPI_MEDIA_TYPE_DVDPLUSR_DUALLAYER=8
  #IMAPI_MEDIA_TYPE_DVDDASHR=9
  #IMAPI_MEDIA_TYPE_DVDDASHRW=10
  #IMAPI_MEDIA_TYPE_DVDDASHR_DUALLAYER=11
  #IMAPI_MEDIA_TYPE_DISK=12
  #IMAPI_MEDIA_TYPE_DVDPLUSRW_DUALLAYER=13
  #IMAPI_MEDIA_TYPE_HDDVDROM=14
  #IMAPI_MEDIA_TYPE_HDDVDR=15
  #IMAPI_MEDIA_TYPE_HDDVDRAM=16
  #IMAPI_MEDIA_TYPE_BDROM=17
  #IMAPI_MEDIA_TYPE_BDR=18
  #IMAPI_MEDIA_TYPE_BDRE=19
  #IMAPI_MEDIA_TYPE_MAX=19
EndEnumeration
Enumeration ; _IMAPI_READ_TRACK_ADDRESS_TYPE
  #IMAPI_READ_TRACK_ADDRESS_TYPE_LBA=0
  #IMAPI_READ_TRACK_ADDRESS_TYPE_TRACK=1
  #IMAPI_READ_TRACK_ADDRESS_TYPE_SESSION=2
EndEnumeration
Enumeration ; _IMAPI_FEATURE_PAGE_TYPE
  #IMAPI_FEATURE_PAGE_TYPE_PROFILE_LIST=0
  #IMAPI_FEATURE_PAGE_TYPE_CORE=1
  #IMAPI_FEATURE_PAGE_TYPE_MORPHING=2
  #IMAPI_FEATURE_PAGE_TYPE_REMOVABLE_MEDIUM=3
  #IMAPI_FEATURE_PAGE_TYPE_WRITE_PROTECT=4
  #IMAPI_FEATURE_PAGE_TYPE_RANDOMLY_READABLE=16
  #IMAPI_FEATURE_PAGE_TYPE_CD_MULTIREAD=29
  #IMAPI_FEATURE_PAGE_TYPE_CD_READ=30
  #IMAPI_FEATURE_PAGE_TYPE_DVD_READ=31
  #IMAPI_FEATURE_PAGE_TYPE_RANDOMLY_WRITABLE=32
  #IMAPI_FEATURE_PAGE_TYPE_INCREMENTAL_STREAMING_WRITABLE=33
  #IMAPI_FEATURE_PAGE_TYPE_SECTOR_ERASABLE=34
  #IMAPI_FEATURE_PAGE_TYPE_FORMATTABLE=35
  #IMAPI_FEATURE_PAGE_TYPE_HARDWARE_DEFECT_MANAGEMENT=36
  #IMAPI_FEATURE_PAGE_TYPE_WRITE_ONCE=37
  #IMAPI_FEATURE_PAGE_TYPE_RESTRICTED_OVERWRITE=38
  #IMAPI_FEATURE_PAGE_TYPE_CDRW_CAV_WRITE=39
  #IMAPI_FEATURE_PAGE_TYPE_MRW=40
  #IMAPI_FEATURE_PAGE_TYPE_ENHANCED_DEFECT_REPORTING=41
  #IMAPI_FEATURE_PAGE_TYPE_DVD_PLUS_RW=42
  #IMAPI_FEATURE_PAGE_TYPE_DVD_PLUS_R=43
  #IMAPI_FEATURE_PAGE_TYPE_RIGID_RESTRICTED_OVERWRITE=44
  #IMAPI_FEATURE_PAGE_TYPE_CD_TRACK_AT_ONCE=45
  #IMAPI_FEATURE_PAGE_TYPE_CD_MASTERING=46
  #IMAPI_FEATURE_PAGE_TYPE_DVD_DASH_WRITE=47
  #IMAPI_FEATURE_PAGE_TYPE_DOUBLE_DENSITY_CD_READ=48
  #IMAPI_FEATURE_PAGE_TYPE_DOUBLE_DENSITY_CD_R_WRITE=49
  #IMAPI_FEATURE_PAGE_TYPE_DOUBLE_DENSITY_CD_RW_WRITE=50
  #IMAPI_FEATURE_PAGE_TYPE_LAYER_JUMP_RECORDING=51
  #IMAPI_FEATURE_PAGE_TYPE_CD_RW_MEDIA_WRITE_SUPPORT=55
  #IMAPI_FEATURE_PAGE_TYPE_BD_PSEUDO_OVERWRITE=56
  #IMAPI_FEATURE_PAGE_TYPE_DVD_PLUS_R_DUAL_LAYER=59
  #IMAPI_FEATURE_PAGE_TYPE_BD_READ=64
  #IMAPI_FEATURE_PAGE_TYPE_BD_WRITE=65
  #IMAPI_FEATURE_PAGE_TYPE_HD_DVD_READ=80
  #IMAPI_FEATURE_PAGE_TYPE_HD_DVD_WRITE=81
  #IMAPI_FEATURE_PAGE_TYPE_POWER_MANAGEMENT=256
  #IMAPI_FEATURE_PAGE_TYPE_SMART=257
  #IMAPI_FEATURE_PAGE_TYPE_EMBEDDED_CHANGER=258
  #IMAPI_FEATURE_PAGE_TYPE_CD_ANALOG_PLAY=259
  #IMAPI_FEATURE_PAGE_TYPE_MICROCODE_UPDATE=260
  #IMAPI_FEATURE_PAGE_TYPE_TIMEOUT=261
  #IMAPI_FEATURE_PAGE_TYPE_DVD_CSS=262
  #IMAPI_FEATURE_PAGE_TYPE_REAL_TIME_STREAMING=263
  #IMAPI_FEATURE_PAGE_TYPE_LOGICAL_UNIT_SERIAL_NUMBER=264
  #IMAPI_FEATURE_PAGE_TYPE_MEDIA_SERIAL_NUMBER=265
  #IMAPI_FEATURE_PAGE_TYPE_DISC_CONTROL_BLOCKS=266
  #IMAPI_FEATURE_PAGE_TYPE_DVD_CPRM=267
  #IMAPI_FEATURE_PAGE_TYPE_FIRMWARE_INFORMATION=268
  #IMAPI_FEATURE_PAGE_TYPE_AACS=269
  #IMAPI_FEATURE_PAGE_TYPE_VCPS=272
EndEnumeration
Enumeration ; _IMAPI_MODE_PAGE_TYPE
  #IMAPI_MODE_PAGE_TYPE_READ_WRITE_ERROR_RECOVERY=1
  #IMAPI_MODE_PAGE_TYPE_MRW=3
  #IMAPI_MODE_PAGE_TYPE_WRITE_PARAMETERS=5
  #IMAPI_MODE_PAGE_TYPE_CACHING=8
  #IMAPI_MODE_PAGE_TYPE_INFORMATIONAL_EXCEPTIONS=28
  #IMAPI_MODE_PAGE_TYPE_TIMEOUT_AND_PROTECT=29
  #IMAPI_MODE_PAGE_TYPE_POWER_CONDITION=26
  #IMAPI_MODE_PAGE_TYPE_LEGACY_CAPABILITIES=42
EndEnumeration
Enumeration ; _IMAPI_MODE_PAGE_REQUEST_TYPE
  #IMAPI_MODE_PAGE_REQUEST_TYPE_CURRENT_VALUES=0
  #IMAPI_MODE_PAGE_REQUEST_TYPE_CHANGEABLE_VALUES=1
  #IMAPI_MODE_PAGE_REQUEST_TYPE_DEFAULT_VALUES=2
  #IMAPI_MODE_PAGE_REQUEST_TYPE_SAVED_VALUES=3
EndEnumeration
Enumeration ; _IMAPI_PROFILE_TYPE
  #IMAPI_PROFILE_TYPE_INVALID=0
  #IMAPI_PROFILE_TYPE_NON_REMOVABLE_DISK=1
  #IMAPI_PROFILE_TYPE_REMOVABLE_DISK=2
  #IMAPI_PROFILE_TYPE_MO_ERASABLE=3
  #IMAPI_PROFILE_TYPE_MO_WRITE_ONCE=4
  #IMAPI_PROFILE_TYPE_AS_MO=5
  #IMAPI_PROFILE_TYPE_CDROM=8
  #IMAPI_PROFILE_TYPE_CD_RECORDABLE=9
  #IMAPI_PROFILE_TYPE_CD_REWRITABLE=10
  #IMAPI_PROFILE_TYPE_DVDROM=16
  #IMAPI_PROFILE_TYPE_DVD_DASH_RECORDABLE=17
  #IMAPI_PROFILE_TYPE_DVD_RAM=18
  #IMAPI_PROFILE_TYPE_DVD_DASH_REWRITABLE=19
  #IMAPI_PROFILE_TYPE_DVD_DASH_RW_SEQUENTIAL=20
  #IMAPI_PROFILE_TYPE_DVD_DASH_R_DUAL_SEQUENTIAL=21
  #IMAPI_PROFILE_TYPE_DVD_DASH_R_DUAL_LAYER_JUMP=22
  #IMAPI_PROFILE_TYPE_DVD_PLUS_RW=26
  #IMAPI_PROFILE_TYPE_DVD_PLUS_R=27
  #IMAPI_PROFILE_TYPE_DDCDROM=32
  #IMAPI_PROFILE_TYPE_DDCD_RECORDABLE=33
  #IMAPI_PROFILE_TYPE_DDCD_REWRITABLE=34
  #IMAPI_PROFILE_TYPE_DVD_PLUS_RW_DUAL=42
  #IMAPI_PROFILE_TYPE_DVD_PLUS_R_DUAL=43
  #IMAPI_PROFILE_TYPE_BD_ROM=64
  #IMAPI_PROFILE_TYPE_BD_R_SEQUENTIAL=65
  #IMAPI_PROFILE_TYPE_BD_R_RANDOM_RECORDING=66
  #IMAPI_PROFILE_TYPE_BD_REWRITABLE=67
  #IMAPI_PROFILE_TYPE_HD_DVD_ROM=80
  #IMAPI_PROFILE_TYPE_HD_DVD_RECORDABLE=81
  #IMAPI_PROFILE_TYPE_HD_DVD_RAM=82
  #IMAPI_PROFILE_TYPE_NON_STANDARD=65535
EndEnumeration
Enumeration ; _IMAPI_FORMAT2_DATA_MEDIA_STATE
  #IMAPI_FORMAT2_DATA_MEDIA_STATE_UNKNOWN=0
  #IMAPI_FORMAT2_DATA_MEDIA_STATE_INFORMATIONAL_MASK=15
  #IMAPI_FORMAT2_DATA_MEDIA_STATE_UNSUPPORTED_MASK=64512
  #IMAPI_FORMAT2_DATA_MEDIA_STATE_OVERWRITE_ONLY=1
  #IMAPI_FORMAT2_DATA_MEDIA_STATE_RANDOMLY_WRITABLE=1
  #IMAPI_FORMAT2_DATA_MEDIA_STATE_BLANK=2
  #IMAPI_FORMAT2_DATA_MEDIA_STATE_APPENDABLE=4
  #IMAPI_FORMAT2_DATA_MEDIA_STATE_FINAL_SESSION=8
  #IMAPI_FORMAT2_DATA_MEDIA_STATE_DAMAGED=1024
  #IMAPI_FORMAT2_DATA_MEDIA_STATE_ERASE_REQUIRED=2048
  #IMAPI_FORMAT2_DATA_MEDIA_STATE_NON_EMPTY_SESSION=4096
  #IMAPI_FORMAT2_DATA_MEDIA_STATE_WRITE_PROTECTED=8192
  #IMAPI_FORMAT2_DATA_MEDIA_STATE_FINALIZED=16384
  #IMAPI_FORMAT2_DATA_MEDIA_STATE_UNSUPPORTED_MEDIA=32768
EndEnumeration
Enumeration ; _IMAPI_MEDIA_WRITE_PROTECT_STATE
  #IMAPI_WRITEPROTECTED_UNTIL_POWERDOWN=1
  #IMAPI_WRITEPROTECTED_BY_CARTRIDGE=2
  #IMAPI_WRITEPROTECTED_BY_MEDIA_SPECIFIC_REASON=4
  #IMAPI_WRITEPROTECTED_BY_SOFTWARE_WRITE_PROTECT=8
  #IMAPI_WRITEPROTECTED_BY_DISC_CONTROL_BLOCK=16
  #IMAPI_WRITEPROTECTED_READ_ONLY_MEDIA=16384
EndEnumeration
Enumeration ; _IMAPI_FORMAT2_RAW_CD_DATA_SECTOR_TYPE
  #IMAPI_FORMAT2_RAW_CD_SUBCODE_PQ_ONLY=1
  #IMAPI_FORMAT2_RAW_CD_SUBCODE_IS_COOKED=2
  #IMAPI_FORMAT2_RAW_CD_SUBCODE_IS_RAW=3
EndEnumeration
Enumeration ; PlatformId
  #PlatformX86=0
  #PlatformPowerPC=1
  #PlatformMac=2
EndEnumeration
Enumeration ; EmulationType
  #EmulationNone=0
  #Emulation12MFloppy=1
  #Emulation144MFloppy=2
  #Emulation288MFloppy=3
  #EmulationHardDisk=4
EndEnumeration
Enumeration ; FsiFileSystems
  #FsiFileSystemNone=0
  #FsiFileSystemISO9660=1
  #FsiFileSystemJoliet=2
  #FsiFileSystemUDF=4
  #FsiFileSystemUnknown=1073741824
EndEnumeration
Enumeration ; _IMAPI_MEDIA_PHYSICAL_TYPE
  #IMAPI_MEDIA_TYPE_UNKNOWN=0
  #IMAPI_MEDIA_TYPE_CDROM=1
  #IMAPI_MEDIA_TYPE_CDR=2
  #IMAPI_MEDIA_TYPE_CDRW=3
  #IMAPI_MEDIA_TYPE_DVDROM=4
  #IMAPI_MEDIA_TYPE_DVDRAM=5
  #IMAPI_MEDIA_TYPE_DVDPLUSR=6
  #IMAPI_MEDIA_TYPE_DVDPLUSRW=7
  #IMAPI_MEDIA_TYPE_DVDPLUSR_DUALLAYER=8
  #IMAPI_MEDIA_TYPE_DVDDASHR=9
  #IMAPI_MEDIA_TYPE_DVDDASHRW=10
  #IMAPI_MEDIA_TYPE_DVDDASHR_DUALLAYER=11
  #IMAPI_MEDIA_TYPE_DISK=12
  #IMAPI_MEDIA_TYPE_DVDPLUSRW_DUALLAYER=13
  #IMAPI_MEDIA_TYPE_HDDVDROM=14
  #IMAPI_MEDIA_TYPE_HDDVDR=15
  #IMAPI_MEDIA_TYPE_HDDVDRAM=16
  #IMAPI_MEDIA_TYPE_BDROM=17
  #IMAPI_MEDIA_TYPE_BDR=18
  #IMAPI_MEDIA_TYPE_BDRE=19
  #IMAPI_MEDIA_TYPE_MAX=19
EndEnumeration
Enumeration ; FsiItemType
  #FsiItemNotFound=0
  #FsiItemDirectory=1
  #FsiItemFile=2
EndEnumeration
; ##########################################
; #               Interface                #
; ##########################################
CompilerIf Defined(IWriteEngine2EventArgs,#PB_Interface) = #False
Interface IWriteEngine2EventArgs Extends IDispatch; CD Write Engine
  get_StartLba(dispidMember.l)
  get_SectorCount(dispidMember.l)
  get_LastReadLba(dispidMember.l)
  get_LastWrittenLba(dispidMember.l)
  get_TotalSystemBuffer(dispidMember.l)
  get_UsedSystemBuffer(dispidMember.l)
  get_FreeSystemBuffer(dispidMember.l)
EndInterface
CompilerEndIf
CompilerIf Defined(IDiscFormat2DataEventArgs,#PB_Interface) = #False
Interface IDiscFormat2DataEventArgs Extends IWriteEngine2EventArgs; Track-at-once Data Writer
  get_ElapsedTime(dispidMember.l)
  get_RemainingTime(dispidMember.l)
  get_TotalTime(dispidMember.q)
  get_CurrentAction(dispidMember.l)
EndInterface
CompilerEndIf
CompilerIf Defined(IDiscFormat2TrackAtOnceEventArgs,#PB_Interface) = #False
Interface IDiscFormat2TrackAtOnceEventArgs Extends IWriteEngine2EventArgs; CD Track-at-once Audio Writer Event Arguments
  get_CurrentTrackNumber(dispidMember.l)
  get_CurrentAction(dispidMember.q)
  get_ElapsedTime(dispidMember.l)
  get_RemainingTime(dispidMember.l)
EndInterface
CompilerEndIf
CompilerIf Defined(IDiscFormat2RawCDEventArgs,#PB_Interface) = #False
Interface IDiscFormat2RawCDEventArgs Extends IWriteEngine2EventArgs; CD Disc-At-Once RAW Writer Event Arguments
  get_CurrentAction(dispidMember.l)
  get_ElapsedTime(dispidMember.l)
  get_RemainingTime(dispidMember.l)
EndInterface
CompilerEndIf
CompilerIf Defined(IWriteSpeedDescriptor,#PB_Interface) = #False
Interface IWriteSpeedDescriptor Extends IDispatch; A single optical drive Write Speed Configuration
  get_MediaType(dispidMember.l)
  get_RotationTypeIsPureCAV(dispidMember.l)
  get_WriteSpeed(dispidMember.l)
EndInterface
CompilerEndIf
CompilerIf Defined(DDiscMaster2Events,#PB_Interface) = #False
Interface DDiscMaster2Events Extends IDispatch; Provides notification of the arrival/removal of CD/DVD (optical) devices.
  NotifyDeviceAdded(*object.IDispatch,uniqueId.p-bstr)
  NotifyDeviceRemoved(*object.IDispatch,uniqueId.p-bstr)
EndInterface
CompilerEndIf
CompilerIf Defined(IBootOptions,#PB_Interface) = #False
Interface IBootOptions Extends IDispatch 
  get_BootImage(dispidMember.l) 
  get_Manufacturer(dispidMember.l) 
  put_Manufacturer(dispidMember.p-bstr) 
  get_PlatformId(dispidMember.l) 
  put_PlatformId(dispidMember.l) 
  get_Emulation(dispidMember.l) 
  put_Emulation(dispidMember.l) 
  get_ImageSize(dispidMember.l) 
  AssignBootImage(newVal.l) 
EndInterface
CompilerEndIf
CompilerIf Defined(IDiscMaster2,#PB_Interface) = #False
Interface IDiscMaster2 Extends IDispatch ;<<<<<
  get__NewEnum(dispidMember.l)
  get_Item(index.l, value)
  get_Count(index.l)
  get_IsSupportedEnvironment(index.l)
EndInterface
CompilerEndIf
CompilerIf Defined(DWriteEngine2Events,#PB_Interface) = #False
Interface DWriteEngine2Events Extends IDispatch; Provides notification of the progress of the WriteEngine2 writing.
  Update(*object.IDispatch,*progress.IDispatch)
EndInterface
CompilerEndIf
CompilerIf Defined(DDiscFormat2EraseEvents,#PB_Interface) = #False
Interface DDiscFormat2EraseEvents Extends IDispatch ; Provides notification of media erase progress.
  Update(*object.IDispatch,elapsedSeconds.l,estimatedTotalSeconds.l)
EndInterface
CompilerEndIf
CompilerIf Defined(DDiscFormat2DataEvents,#PB_Interface) = #False
Interface DDiscFormat2DataEvents Extends IDispatch ; Data Writer 
  Update(*object.IDispatch,*progress.IDispatch)
EndInterface
CompilerEndIf
CompilerIf Defined(DDiscFormat2TrackAtOnceEvents,#PB_Interface) = #False
Interface DDiscFormat2TrackAtOnceEvents Extends IDispatch ; CD Track-at-Once Audio Writer Events <<<<<<<
  Update(*object.IDispatch,*progress.IDispatch)
EndInterface
CompilerEndIf
CompilerIf Defined(DDiscFormat2RawCDEvents,#PB_Interface) = #False
Interface DDiscFormat2RawCDEvents Extends IDispatch ; CD Disc-At-Once RAW Writer Events <<<<<<
  Update(*object.IDispatch,*progress.IDispatch)
EndInterface
CompilerEndIf
CompilerIf Defined(IDiscRecorder2,#PB_Interface) = #False
Interface IDiscRecorder2 Extends IDispatch ;
  EjectMedia()
  CloseTray()
  AcquireExclusiveAccess(force.w,__MIDL__IDiscRecorder20000.p-bstr)
  ReleaseExclusiveAccess()
  DisableMcn()
  EnableMcn()
  InitializeDiscRecorder(recorderUniqueId)
  get_ActiveDiscRecorder(recorderUniqueId.l)
  get_VendorId(recorderUniqueId.l)
  get_ProductId(recorderUniqueId.l)
  get_ProductRevision(recorderUniqueId.l)
  get_VolumeName(recorderUniqueId.l) 
  get_VolumePathNames(recorderUniqueId.l) ; value.SAFEARRAY
  get_DeviceCanLoadMedia(recorderUniqueId.l)
  get_LegacyDeviceNumber(recorderUniqueId.l)
  get_SupportedFeaturePages(recorderUniqueId.l) ; value.SAFEARRAY
  get_CurrentFeaturePages(recorderUniqueId.q) ; value.SAFEARRAY
  get_SupportedProfiles(recorderUniqueId.l) ; value.SAFEARRAY
  get_CurrentProfiles(recorderUniqueId.l) ; value.SAFEARRAY
  get_SupportedModePages(recorderUniqueId.l) ; value.SAFEARRAY
  get_ExclusiveAccessOwner(recorderUniqueId.l) 
EndInterface
CompilerEndIf
; IDiscRecorder2Ex information: Note - You cannot access this functionality from script, haven't tried in PB
; To get an instance of this Interface, create an instance of the IDiscRecorder2 Interface And then call the IDiscRecorder2\QueryInterface
; method To retrieve the IDiscRecorder2Ex Interface.
CompilerIf Defined(IDiscRecorder2Ex,#PB_Interface) = #False
Interface IDiscRecorder2Ex Extends IUnknown ; 
  SendCommandNoData(Cdb.l,CdbSize.l,SenseBuffer.l,Timeout.l)
  SendCommandSendDataToDevice(Cdb.l,CdbSize.l,SenseBuffer.l,Timeout.l,Buffer.l,BufferSize.l)
  SendCommandGetDataFromDevice(Cdb.l,CdbSize.l,SenseBuffer.l,Timeout.l,Buffer.l,BufferSize.l,BufferFetched.l)
  ReadDvdStructure(format.l,address.l,layer.l,agid.l,Data_.l,Count.l)
  SendDvdStructure(format.l,Data_.l,Count.l)
  GetAdapterDescriptor(Data_.l,byteSize.l)
  GetDeviceDescriptor(Data_.l,byteSize.l)
  GetDiscInformation(discInformation.l,byteSize.l)
  GetTrackInformation(address.l,addressType.l,trackInformation.l,byteSize.l)
  GetFeaturePage(requestedFeature.l,currentFeatureOnly.b,featureData.l,byteSize.l)
  GetModePage(requestedModePage.l,requestType.l,modePageData.l,byteSize.l)
  SetModePage(requestType.l,Data_.l,byteSize.l)
  GetSupportedFeaturePages(currentFeatureOnly.b,featureData.l,byteSize.l)
  GetSupportedProfiles(currentOnly.b,profileTypes.l,validProfiles.l)
  GetSupportedModePages(requestType.l,modePageTypes.l,validPages.l)
  GetByteAlignmentMask(value.l)
  GetMaximumNonPageAlignedTransferSize(value.l)
  GetMaximumPageAlignedTransferSize(value.l)
EndInterface
CompilerEndIf
CompilerIf Defined(IWriteEngine2,#PB_Interface) = #False
Interface IWriteEngine2 Extends IDispatch ; Write Engine 
  WriteSection(Data_.l,startingBlockAddress.l,numberOfBlocks.l)
  CancelWrite()
  put_Recorder(Data_.l)
  get_Recorder(Data_.l)
  put_UseStreamingWrite12(Data_.w)
  get_UseStreamingWrite12(Data_.l)
  put_StartingSectorsPerSecond(Data_.l)
  get_StartingSectorsPerSecond(Data_.l)
  put_EndingSectorsPerSecond(Data_.l)
  get_EndingSectorsPerSecond(Data_.l)
  put_BytesPerSector(Data_.l)
  get_BytesPerSector(Data_.l)
  get_WriteInProgress(Data_.l)
EndInterface
CompilerEndIf
CompilerIf Defined(IDiscFormat2,#PB_Interface) = #False
Interface IDiscFormat2 Extends IDispatch ;
  IsRecorderSupported(Recorder.l, value.l)
  IsCurrentMediaSupported(Recorder.l, value.l)
  get_MediaPhysicallyBlank(Recorder.l)
  get_MediaHeuristicallyBlank(Recorder.l)
  get_SupportedMediaTypes(Recorder.l) ;value.SAFEARRAY
EndInterface
CompilerEndIf
CompilerIf Defined(IDiscFormat2Erase,#PB_Interface) = #False
Interface IDiscFormat2Erase Extends IDiscFormat2 ; 
  put_Recorder(Recorder.l)
  get_Recorder(Recorder.l)
  put_FullErase(Recorder.w)
  get_FullErase(Recorder.l)
  get_CurrentPhysicalMediaType(Recorder.l)
  put_ClientName(Recorder.p-bstr)
  get_ClientName(Recorder.l)
  EraseMedia()
EndInterface
CompilerEndIf
CompilerIf Defined(IDiscFormat2Data,#PB_Interface) = #False
Interface IDiscFormat2Data Extends IDiscFormat2
  put_Recorder(Recorder.l)
  get_Recorder(Recorder.l)
  put_BufferUnderrunFreeDisabled(Recorder.w)
  get_BufferUnderrunFreeDisabled(Recorder.l)
  put_PostgapAlreadyInImage(Recorder.w)
  get_PostgapAlreadyInImage(Recorder.l)
  get_CurrentMediaStatus(Recorder.l)
  get_WriteProtectStatus(Recorder.l)
  get_TotalSectorsOnMedia(Recorder.l)
  get_FreeSectorsOnMedia(Recorder.l)
  get_NextWritableAddress(Recorder.l)
  get_StartAddressOfPreviousSession(Recorder.l)
  get_LastWrittenAddressOfPreviousSession(Recorder.l)
  put_ForceMediaToBeClosed(Recorder.w)
  get_ForceMediaToBeClosed(value.l)
  put_DisableConsumerDvdCompatibilityMode(Recorder.w)
  get_DisableConsumerDvdCompatibilityMode(Recorder.l)
  get_CurrentPhysicalMediaType(Recorder.l)
  put_ClientName(Recorder.p-bstr)
  get_ClientName(Recorder.p-bstr)
  get_RequestedWriteSpeed(Recorder.l)
  get_RequestedRotationTypeIsPureCAV(Recorder.l)
  get_CurrentWriteSpeed(Recorder.l)
  get_CurrentRotationTypeIsPureCAV(Recorder.l)
  get_SupportedWriteSpeeds(Recorder.l) ; supportedSpeeds.SAFEARRAY 
  get_SupportedWriteSpeedDescriptors(Recorder.l)
  put_ForceOverwrite(Recorder.w) 
  get_ForceOverwrite(Recorder.l)
  get_MultisessionInterfaces(Recorder.l)
  Write(Data_.l)
  CancelWrite()
  SetWriteSpeed(RequestedSectorsPerSecond.l,RotationTypeIsPureCAV.w)
EndInterface
CompilerEndIf
CompilerIf Defined(IDiscFormat2TrackAtOnce,#PB_Interface) = #False
Interface IDiscFormat2TrackAtOnce Extends IDiscFormat2 ; CD Track-at-Once Audio Writer
  PrepareMedia()
  AddAudioTrack(Data_.l)
  CancelAddTrack()
  ReleaseMedia()
  SetWriteSpeed(RequestedSectorsPerSecond.l,RotationTypeIsPureCAV.w)
  put_Recorder(RequestedSectorsPerSecond.l)
  get_Recorder(RequestedSectorsPerSecond.l)
  put_BufferUnderrunFreeDisabled(RequestedSectorsPerSecond.w)
  get_BufferUnderrunFreeDisabled(RequestedSectorsPerSecond.l)
  get_NumberOfExistingTracks(RequestedSectorsPerSecond.l)
  get_TotalSectorsOnMedia(RequestedSectorsPerSecond.l)
  get_FreeSectorsOnMedia(RequestedSectorsPerSecond.l)
  get_UsedSectorsOnMedia(RequestedSectorsPerSecond.l)
  put_DoNotFinalizeMedia(RequestedSectorsPerSecond.w)
  get_DoNotFinalizeMedia(RequestedSectorsPerSecond.l)
  get_ExpectedTableOfContents(RequestedSectorsPerSecond.l)
  get_CurrentPhysicalMediaType(RequestedSectorsPerSecond.l)
  put_ClientName(RequestedSectorsPerSecond.p-bstr)
  get_ClientName(RequestedSectorsPerSecond.l)
  get_RequestedWriteSpeed(RequestedSectorsPerSecond.l)
  get_RequestedRotationTypeIsPureCAV(RequestedSectorsPerSecond.l)
  get_CurrentWriteSpeed(RequestedSectorsPerSecond.l)
  get_CurrentRotationTypeIsPureCAV(RequestedSectorsPerSecond.l)
  get_SupportedWriteSpeeds(RequestedSectorsPerSecond.l)
  get_SupportedWriteSpeedDescriptors(RequestedSectorsPerSecond.l)
EndInterface
CompilerEndIf
CompilerIf Defined(IDiscFormat2RawCD,#PB_Interface) = #False
Interface IDiscFormat2RawCD Extends IDiscFormat2 ; CD Disc-At-Once RAW Writer
  PrepareMedia()
  WriteMedia(Data_.l)
  WriteMedia2(Data_.l,streamLeadInSectors.l)
  CancelWrite()
  ReleaseMedia()
  SetWriteSpeed(RequestedSectorsPerSecond.l,RotationTypeIsPureCAV.w)
  put_Recorder(RequestedSectorsPerSecond.l)
  get_Recorder(RequestedSectorsPerSecond.q)
  put_BufferUnderrunFreeDisabled(RequestedSectorsPerSecond.w)
  get_BufferUnderrunFreeDisabled(RequestedSectorsPerSecond.l)
  get_StartOfNextSession(RequestedSectorsPerSecond.l)
  get_LastPossibleStartOfLeadout(RequestedSectorsPerSecond.l)
  get_CurrentPhysicalMediaType(RequestedSectorsPerSecond.l)
  get_SupportedSectorTypes(RequestedSectorsPerSecond.l)
  put_RequestedSectorType(RequestedSectorsPerSecond.l)
  get_RequestedSectorType(RequestedSectorsPerSecond.l)
  put_ClientName(RequestedSectorsPerSecond.p-bstr)
  get_ClientName(RequestedSectorsPerSecond.l)
  get_RequestedWriteSpeed(RequestedSectorsPerSecond.l)
  get_RequestedRotationTypeIsPureCAV(RequestedSectorsPerSecond.l)
  get_CurrentWriteSpeed(RequestedSectorsPerSecond.q)
  get_CurrentRotationTypeIsPureCAV(RequestedSectorsPerSecond.l)
  get_SupportedWriteSpeeds(RequestedSectorsPerSecond.l)
  get_SupportedWriteSpeedDescriptors(RequestedSectorsPerSecond.l)
EndInterface
CompilerEndIf 
CompilerIf Defined(IFileSystemImage,#PB_Interface) = #False
Interface IFileSystemImage Extends IDispatch
  get_Root(dispidMember.l) 
  get_SessionStartBlock(dispidMember.l) 
  put_SessionStartBlock(dispidMember.l) 
  get_FreeMediaBlocks(dispidMember.l) 
  put_FreeMediaBlocks(dispidMember.l) 
  SetMaxMediaBlocksFromDevice(discRecorder.l) 
  get_UsedBlocks(discRecorder.l) 
  get_VolumeName(discRecorder.l) 
  put_VolumeName(discRecorder.p-bstr) 
  get_ImportedVolumeName(discRecorder.l) 
  get_BootImageOptions(discRecorder.l) 
  put_BootImageOptions(discRecorder.l) 
  get_FileCount(discRecorder.l) 
  get_DirectoryCount(discRecorder.l) 
  get_WorkingDirectory(discRecorder.l) 
  put_WorkingDirectory(discRecorder.p-bstr) 
  get_ChangePoint(discRecorder.l) 
  get_StrictFileSystemCompliance(discRecorder.l) 
  put_StrictFileSystemCompliance(discRecorder.w) 
  get_UseRestrictedCharacterSet(discRecorder.l) 
  put_UseRestrictedCharacterSet(discRecorder.w) 
  get_FileSystemsToCreate(discRecorder.l) 
  put_FileSystemsToCreate(discRecorder.l) 
  get_FileSystemsSupported(discRecorder.l) 
  put_UDFRevision(discRecorder.l) 
  get_UDFRevision(discRecorder.l) 
  get_UDFRevisionsSupported(discRecorder.l) 
  ChooseImageDefaults(discRecorder.l) 
  ChooseImageDefaultsForMediaType(value.l) 
  put_ISO9660InterchangeLevel(value.l) 
  get_ISO9660InterchangeLevel(value.l) 
  get_ISO9660InterchangeLevelsSupported(value.l) 
  CreateResultImage(a.l) 
  Exists(FullPath.p-bstr) 
  CalculateDiscIdentifier(discIdentifier.p-bstr)
  IdentifyFileSystemsOnDisc(discRecorder.l) 
  GetDefaultFileSystemForImport(fileSystems.l) 
  ImportFileSystem(importedFileSystem.l) 
  ImportSpecificFileSystem(fileSystemToUse.l) 
  RollbackToChangePoint(ChangePoint.l) 
  LockInChangePoint() 
  CreateDirectoryItem(Name.p-bstr)
  CreateFileItem(Name.p-bstr) 
  get_VolumeNameUDF(Name.l) 
  get_VolumeNameJoliet(Name.l) 
  get_VolumeNameISO9660(Name.l) 
  get_StageFiles(Name.l) 
  put_StageFiles(Name.w) 
  get_MultisessionInterfaces(Name.l) 
  put_MultisessionInterfaces(Name.l) 
EndInterface
CompilerEndIf
; Information : IFileSystemImage2 - only available for Windows Vista SP1 and Windows Server 2008.
; write multiple boot entries or boot images required for the EFI/UEFI support. For example, boot media with boot straps for both Windows XP and Windows Vista.
; included here for future use and expansion
CompilerIf Defined(IFileSystemImage2,#PB_Interface) = #False
Interface IFileSystemImage2 Extends IFileSystemImage
  get_BootImageOptionsArray(pVal.l) ; out pVal.SAFEARRAY 
  put_BootImageOptionsArray(newVal.l) ; in newVal.SAFEARRAY
EndInterface
CompilerEndIf
CompilerIf Defined(IProgressItems,#PB_Interface) = #False
Interface IProgressItems Extends IDispatch; Progress item block mapping collection
  get__NewEnum(dispidMember.l)
  get_Item(Index.l)
  get_Count(Index.l)
  ProgressItemFromBlock(block.l)
  ProgressItemFromDescription(Description.p-bstr)
  get_EnumProgressItems(Description.l)
EndInterface
CompilerEndIf
CompilerIf Defined(IProgressItem,#PB_Interface) = #False
Interface IProgressItem Extends IDispatch; FileSystemImageResult progress item
  get_Description(dispidMember.l)
  get_FirstBlock(dispidMember.l)
  get_LastBlock(dispidMember.l)
  get_BlockCount(dispidMember.q)
EndInterface
CompilerEndIf
CompilerIf Defined(IFileSystemImageResult,#PB_Interface) = #False
Interface IFileSystemImageResult Extends IDispatch 
  get_ImageStream(dispidMember.l) 
  get_ProgressItems(dispidMember.l) 
  get_TotalBlocks(dispidMember.l) 
  get_BlockSize(dispidMember.l) 
  get_DiscId(dispidMember.l) 
EndInterface
CompilerEndIf
CompilerIf Defined(IFsiItem,#PB_Interface) = #False
Interface IFsiItem Extends IDispatch
  get_Name(pVal.l)
  get_FullPath(pVal.l)
  get_CreationTime(pVal.l)
  put_CreationTime(newVal.l)
  get_LastAccessedTime(pVal.l)
  put_LastAccessedTime(newval.l)
  get_LastModifiedTime(pVal.l)
  put_LastModifiedTime(newVal.l)
  get_IsHidden(pVal.l)
  put_IsHidden(newVal.l)
  FileSystemName(fileSystem.l, pVal.l)
  FileSystemPath(fileSystem.l, pVal.l)
EndInterface
CompilerEndIf
CompilerIf Defined(IFsiDirectoryItem,#PB_Interface) = #False
Interface IFsiDirectoryItem Extends IFsiItem
  get__NewEnum(fileSystem.l) 
  get_Item(path.p-bstr) 
  get_Count(path.l) 
  get_EnumFsiItems(path.l) 
  AddDirectory(path.p-bstr) 
  AddFile(path.p-bstr,fileData.l) 
  AddTree(sourceDirectory.p-bstr,includeBaseDirectory.w) 
  Add(Item.l) 
  Remove(path.p-bstr) 
  RemoveTree(path.p-bstr) 
EndInterface
CompilerEndIf
CompilerIf Defined(IFsiFileItem,#PB_Interface) = #False
Interface IFsiFileItem Extends IFsiItem
  get_DataSize(pVal.l)
  get_DataSize32BitLow(pVal.l)
  get_DataSize32BitHigh(pVal.l)
  get_Data(pVal.l)
  put_Data(newVal.l)
EndInterface
CompilerEndIf
CompilerIf Defined(IMultisession,#PB_Interface) = #False
Interface IMultisession Extends IDispatch ; Generic multisession support interface.
  get_IsSupportedOnCurrentMediaState(value.l)
  put_InUse(value.w)
  get_InUse(value.l)
  get_ImportRecorder(value.l)
EndInterface
CompilerEndIf
CompilerIf Defined(IMultisessionSequential,#PB_Interface) = #False
Interface IMultisessionSequential Extends IMultisession ; Sequential multisession support interface.
  get_IsFirstDataSession(value.l)
  get_StartAddressOfPreviousSession(value.l)
  get_LastWrittenAddressOfPreviousSession(value.l)
  get_NextWritableAddress(value.l)
  get_FreeSectorsOnMedia(value.l)
EndInterface
CompilerEndIf
CompilerIf Defined(IStreamPseudoRandomBased,#PB_Interface) = #False
Interface IStreamPseudoRandomBased Extends IStream; Pseudo-random based IStream data (implementation dependent)
  put_Seed(value.l)
  get_Seed(value.l)
  put_ExtendedSeed(values.l,eCount.l)
  get_ExtendedSeed(values.l,eCount.l)
EndInterface
CompilerEndIf
CompilerIf Defined(IStreamConcatenate,#PB_Interface) = #False
Interface IStreamConcatenate Extends IStream; Stream concatenation
  Initialize(stream1.l,stream2.l)
  Initialize2(streams.l,streamCount.l)
  Append(stream.l)
  Append2(streams.l,streamCount.l)
EndInterface
CompilerEndIf
CompilerIf Defined(IStreamInterleave,#PB_Interface) = #False
Interface IStreamInterleave Extends IStream; Stream interleave: each stream gets interleaveSize bytes, then cycles to the next stream
  Initialize(streams.l,interleaveSizes.l,streamCount.l)
EndInterface
CompilerEndIf
; ##########################################
; #               Structures               #
; ##########################################
CompilerIf Defined(_STORAGE_DEVICE_DESCRIPTOR,#PB_Structure) = #False
Structure _STORAGE_DEVICE_DESCRIPTOR
  Version.l
  Size.l
  DeviceType.b
  DeviceTypeModifier.b
  RemovableMedia.l
  CommandQueueing.l
  VendorIdOffset.l
  ProductIdOffset.l
  ProductRevisionOffset.l
  SerialNumberOffset.l
  BusType.l
  RawPropertiesLength.l 
  RawDeviceProperties.b[1]
EndStructure
CompilerEndIf
CompilerIf Defined(SAFEARRAYBOUND,#PB_Structure) = #False
Structure SAFEARRAYBOUND ; ; thanks to Shardik for this
  cElements.L  ; # of elements in the array dimension 
  lLbound.L    ; Lower bounds of the array dimension 
EndStructure
CompilerEndIf 
CompilerIf Defined(SAFEARRAY,#PB_Structure) = #False
Structure SAFEARRAY ; ; thanks to Shardik for this
  cDims.W 
  fFeatures.W 
  cbElements.L 
  cLocks.L 
  pvData.L 
  rgsabound.SAFEARRAYBOUND[60] 
EndStructure
CompilerEndIf
; since PB handles quad
CompilerIf Defined(_ULARGE_INTEGER,#PB_Structure) = #False
Structure _ULARGE_INTEGER
  QuadPart.q
EndStructure
CompilerEndIf
; since PB handles quad
CompilerIf Defined(_LARGE_INTEGER,#PB_Structure) = #False
Structure _LARGE_INTEGER
  QuadPart.q
EndStructure
CompilerEndIf
; see ; STATSTG and tagSTATSTG
CompilerIf Defined(tagCONNECTDATA,#PB_Structure) = #False
Structure tagCONNECTDATA
  *pUnk.IUnknown
  dwCookie.l
EndStructure
CompilerEndIf
; STATSTG as currently used
CompilerIf Defined(STATSTG,#PB_Structure) = #False
Structure STATSTG
  pwcsName.l 
  type.l 
  cbSize.q 
  mtime.FILETIME 
  ctime.FILETIME 
  atime.FILETIME
  grfMode.f 
  grfLocksSupported.l 
  clsid.GUID 
  grfStateBits.l 
  reserved.l
EndStructure
CompilerEndIf
; STATSTG as currently defined for Imapiv2 and in current SDK for imapiv2
CompilerIf Defined(tagSTATSTG,#PB_Structure) = #False
Structure tagSTATSTG
  pwcsName.l ; p-unicode
  type.l
  cbSize._ULARGE_INTEGER
  mtime.l
  ctime.l
  atime.l
  grfMode.l
  grfLocksSupported.l
  clsid.IWriteEngine2EventArgs
  grfStateBits.l
  reserved.l
EndStructure
CompilerEndIf
; STATSTG as currently defined for Imapiv2 and in current SDK for imapiv2 File System
;Structure tagSTATSTG
CompilerIf Defined(tagSTATSTG_FS,#PB_Structure) = #False
Structure tagSTATSTG_FS ; changed name to avoid conflict while testing
  pwcsName.l ; p-unicode
  type.l
  cbSize.l
  mtime.l
  ctime.l
  atime.l
  grfMode.l
  grfLocksSupported.l
  clsid.l
  grfStateBits.l
  reserved.l
EndStructure
CompilerEndIf
; ##########################################
; #         Helper/wrap/macro/procedures   #
; ##########################################
Procedure.s GetVariantString(*Variant.VARIANT) ; thanks to Shardik for this
  Protected String.S = "" 
  If VariantChangeType_(*Variant, *Variant, 0, #VT_BSTR) = #S_OK 
    String = PeekS(*Variant\bstrVal, -1, #PB_Unicode) 
    VariantClear_(*Variant) 
  Else 
    Debug "VariantChangeType() failed!" 
  EndIf 
  ProcedureReturn String  
EndProcedure
Procedure.s sfs_Uni2Ansi(Pointer) ; credit to the originator for this 
  Buffer.s=Space(512) 
  WideCharToMultiByte_(#CP_ACP,0,Pointer,-1,@Buffer,512,0,0) 
  ProcedureReturn Buffer 
EndProcedure 
Procedure DiscMaster_obj() ; call this to create IDiscMaster2 object called DiscMaster
Global DiscMaster.IDiscMaster2
CoCreateInstance_(?CLSID_MsftDiscMaster2,0,1,?IID_IDiscMaster2,@DiscMaster.IDiscMaster2)
ProcedureReturn
EndProcedure
Procedure Recorder_obj() ; call this to create IDiscRecorder2 called Recorder
Global Recorder.IDiscRecorder2
CoCreateInstance_(?CLSID_MsftDiscRecorder2,0,1,?IID_IDiscRecorder2,@Recorder.IDiscRecorder2)
ProcedureReturn
EndProcedure
Procedure Format2Erase_obj() ; call this to create IDiscFormat2Erase object called Format2Erase
Global Format2Erase.IDiscFormat2Erase
CoCreateInstance_(?CLSID_MsftDiscFormat2Erase,0,1,?IID_IDiscFormat2Erase,@Format2Erase.IDiscFormat2Erase)
ProcedureReturn
EndProcedure
Procedure FileSystemImgage_obj() ; call this to create IFileSystemImage object called FileSystemImgage
Global FileSystemImgage.IFileSystemImage
CoCreateInstance_(?CLSID_MsftFileSystemImage,0,1,?IID_IFileSystemImage,@FileSystemImgage.IFileSystemImage)
ProcedureReturn
EndProcedure
Procedure DataWriter_Format2Data_obj() ; call this to create IDiscFormat2Data called DataWriter_Format2Data
Global DataWriter_Format2Data.IDiscFormat2Data
CoCreateInstance_(?CLSID_MsftDiscFormat2Data,0,1,?IID_IDiscFormat2Data,@DataWriter_Format2Data.IDiscFormat2Data)
ProcedureReturn
EndProcedure
Procedure DiscFormat2RawCD_obj() ; call this to create IDiscFormat2RawCD object called DiscFormat2RawCD
Global DiscFormat2RawCD.IDiscFormat2RawCD
CoCreateInstance_(?CLSID_MsftDiscFormat2RawCD,0,1,?IID_IDiscFormat2RawCD,@DiscFormat2RawCD.IDiscFormat2RawCD)
ProcedureReturn
EndProcedure
Procedure Format2TrackAtOnce_obj() ; call this to create IDiscFormat2TrackAtOnce object called Format2TrackAtOnce
Global DiscFormat2RawCD.IDiscFormat2RawCD
CoCreateInstance_(?CLSID_MsftDiscFormat2TrackAtOnce,0,1,?IID_IDiscFormat2TrackAtOnce,@Format2TrackAtOnce.IDiscFormat2TrackAtOnce)
ProcedureReturn
EndProcedure
Procedure WriteEngine2_obj() ; call this to create IWriteEngine2 object called WriteEngine2
Global WriteEngine2.IWriteEngine2
CoCreateInstance_(?CLSID_MsftWriteEngine2,0,1,?IID_IWriteEngine2,@WriteEngine2.IWriteEngine2)
ProcedureReturn
EndProcedure
Procedure IBootOptions_obj() ; call this to create IBootOptions object called IBoot_Options
Global IBoot_Options.IBootOptions
CoCreateInstance_(?CLSID_BootOptions,0,1,?IID_IBootOptions,@IBoot_Options.IBootOptions)
ProcedureReturn
EndProcedure
Procedure StreamConcatenate_obj() ; call this to create IStreamConcatenate object called StreamConcatenate
Global StreamConcatenate.IStreamConcatenate
CoCreateInstance_(?CLSID_MsftStreamConcatenate,0,1,?IID_IStreamConcatenate,@StreamConcatenate.IStreamConcatenate)
ProcedureReturn
EndProcedure
Procedure StreamInterleave_obj() ; call this to create IStreamInterleave object called StreamInterleave
Global StreamInterleave.IStreamInterleave
CoCreateInstance_(?CLSID_MsftStreamInterleave,0,1,?IID_IStreamInterleave,@StreamInterleave.IStreamInterleave)
ProcedureReturn
EndProcedure
Procedure StreamPseudoRandomBased_obj() ; call this to create IStreamPseudoRandomBased object called StreamPseudoRandomBased
Global StreamPseudoRandomBased.IStreamPseudoRandomBased
CoCreateInstance_(?CLSID_MsftStreamPrng001,0,1,?IID_IStreamPseudoRandomBased,@StreamPseudoRandomBased.IStreamPseudoRandomBased)
ProcedureReturn
EndProcedure
Procedure DIROBJroot_obj() ; call this to create a FileSystemImgage\get_root IFsiDirectoryItem object called DIROBJ
Global DIROBJ.IFsiDirectoryItem
FileSystemImgage\get_root(@DIROBJ.IFsiDirectoryItem)
ProcedureReturn
EndProcedure
Procedure RESULT_image_obj() ; call this to create IFileSystemImageResult object called RESULT_image
Global RESULT_image.IFileSystemImageResult
FileSystemImgage\CreateResultImage(@RESULT_image.IFileSystemImageResult)
ProcedureReturn
EndProcedure
; Information: CreateBurnIStream()
; Creates a IStream object named dataStream.IStream For .iso file creation Or burning To CD\DVD.
; No parameters
Procedure CreateBurnIStream() ; call this to create dataStream.IStream stream object 
Global dataStream.IStream
CreateStreamOnHGlobal_(0,#True,@dataStream)
ProcedureReturn
EndProcedure
; Information: CreateIsoIStream(in_IsoName.s)
; Creates a IStream object named isoStream.IStream for your .iso file creation
; Produces in_IsoName.iso located at full path To where .iso is created on hard drive - i.e..."C:\myiso.iso" Or "C:\temp\myiso.iso"
; where:
; In = in_IsoName.s = full path To where .iso is To be created on hard drive - i.e..."C:\myiso.iso" or "C:\temp\myiso.iso"
Procedure CreateIsoIStream(in_IsoName.s) ; call this to create isoStream.IStream stream object
Global isoStream.IStream
SHCreateStreamOnFileEx(in_IsoName,#STGM_WRITE|#STGM_CREATE,0,0,0,@isoStream)
ProcedureReturn
EndProcedure
; Information: CreateBootFileIStream(in_BootFileName.s)
; Creates a IStream object named BootImg.IStream for your boot file image for use in creating bootable CD's/DVD's 
; where:
; in = in_BootFileName.s = full path To the boot file image to use for bootable CD\DVD creation, i.e..."C:\bootimg.bin" or "C:\temp\bootimg.bin"
Procedure CreateBootFileIStream(in_BootFileName.s) ; call this to create BootImg.IStream stream object
Global BootImg.IStream
SHCreateStreamOnFileEx(in_BootFileName,#STGM_READ|#STGM_SHARE_DENY_NONE,0,0,0,@BootImg)
ProcedureReturn
EndProcedure
; Information: CreateBurnIsoIStream(in_iso_burn_file_name.s)
; Creates a IStream object named IsoBurnStream.IStream used to burn a .iso to CD/DVD 
; where:
; in = in_iso_burn_file_name.s = full path To the .iso file to burn to CD\DVD, i.e..."C:\myiso.iso" or "C:\temp\myiso.iso"
Procedure CreateBurnIsoIStream(in_iso_burn_file_name.s) ; call this to create IsoBurnStream.IStream stream object
Global IsoBurnStream.IStream
SHCreateStreamOnFileEx(in_iso_burn_file_name,#STGM_READ|#STGM_SHARE_DENY_NONE,0,0,0,@IsoBurnStream)
ProcedureReturn
EndProcedure
;Information : Eject_Drive(indexx.l)
;In some cases and configurations all objects are released by the Format2Data\Write before any other objects can use the 
;Recorder object, the write function has exclusive access to the drive and is greedy about letting other functions use the objects.
;The Eject function also needs exclusive access but the write function doesn't like to share, as a result the procedure crashes.
;Call this To eject the drive media tray when you need the drive To open For you in one of these special circumstances.
;where:
;indexx.l = the drive index for the drive you need to eject
Procedure Eject_Drive(indexx.l)
pp.variant 
pp\vt = #VT_BSTR
Index.l = indexx.l
CoInitialize_(0)
  DiscMaster_obj()
  DiscMaster\get_Item(Index,@pp\bstrval)
  Recorder_obj()
  Recorder\InitializeDiscRecorder(pp\bstrval)
  DataWriter_Format2Data_obj()
  DataWriter_Format2Data\put_Recorder(Recorder)
  Recorder\EjectMedia()
  
  DiscMaster\Release()
  Recorder\Release()
DataWriter_Format2Data\Release()
CoUninitialize_()
EndProcedure
;Information : Close_Drive(indexx.l) - See information for Eject_Drive_Utility(indexx.l)
;where:
;indexx.l = the drive index for the drive you need to close
Procedure Close_Drive(indexx.l)
pp.variant 
pp\vt = #VT_BSTR
Index.l = indexx.l
CoInitialize_(0)
  DiscMaster_obj()
  DiscMaster\get_Item(Index,@pp\bstrval)
  Recorder_obj()
  Recorder\InitializeDiscRecorder(pp\bstrval)
  DataWriter_Format2Data_obj()
  DataWriter_Format2Data\put_Recorder(Recorder)
  Recorder\CloseTray()
  
  DiscMaster\Release()
  Recorder\Release()
DataWriter_Format2Data\Release()
CoUninitialize_()
EndProcedure
;Information : Check_media(media_unk)
;Checks for unknown media, no media, or unsupported media in drive - uses most common types
;where:
;in = output of IDiscFormat2Data\get_CurrentPhysicalMediaType(@value.l)
Procedure Check_Media(media_unk)  
  Select media_unk
      Case #IMAPI_MEDIA_TYPE_CDROM ; CD-ROM
      media_type_decide.l = #True
      Case #IMAPI_MEDIA_TYPE_CDR ; CD-R
      media_type_decide.l = #True
      Case #IMAPI_MEDIA_TYPE_CDRW ; CD-RW
      media_type_decide.l = #True
      Case #IMAPI_MEDIA_TYPE_DVDROM ; DVD-ROM
      media_type_decide.l = #True
      Case #IMAPI_MEDIA_TYPE_DVDRAM ; DVD-RAM
      media_type_decide.l = #True
      Case #IMAPI_MEDIA_TYPE_DVDPLUSR ; DVD+R
      media_type_decide.l = #True
      Case #IMAPI_MEDIA_TYPE_DVDPLUSRW ; DVD+RW
      media_type_decide.l = #True
      Case #IMAPI_MEDIA_TYPE_DVDPLUSR_DUALLAYER ; DVD+R dual layer
      media_type_decide.l = #True
      Case #IMAPI_MEDIA_TYPE_DVDDASHR ; DVD-R
      media_type_decide.l = #True
      Case #IMAPI_MEDIA_TYPE_DVDDASHRW ; DVD-RW
      media_type_decide.l = #True
      Case #IMAPI_MEDIA_TYPE_DVDDASHR_DUALLAYER ; DVD-R dual layer
      media_type_decide.l = #True
      Case #IMAPI_MEDIA_TYPE_DISK ; Randomly writable
      media_type_decide.l = #True
      ; Media not present OR is unrecognized below here
      Case #IMAPI_MEDIA_TYPE_UNKNOWN 
      media_type_decide.l = #False
      Case #IMAPI_MEDIA_TYPE_HDDVDROM
      media_type_decide.l = #False
      Case #IMAPI_MEDIA_TYPE_BDROM
      media_type_decide.l = #False
  EndSelect
    
If media_type_decide.l = #False
ProcedureReturn #False
Else
ProcedureReturn #True
EndIf 
EndProcedure
; ##########################################
; #                 GUIDs                  #
; ##########################################
DataSection
  CLSID_BootOptions:
    Data.l $2C941FCE
    Data.w $975B,$59BE 
    Data.b $A9,$60,$9A,$2A,$26,$28,$53,$A5
  CLSID_MsftFileSystemImage:
    Data.l $2C941FC5
    Data.w $975B,$59BE 
    Data.b $A9,$60,$9A,$2A,$26,$28,$53,$A5
  CLSID_MsftDiscMaster2:
    Data.l $2735412E
    Data.w $7F64,$5B0F 
    Data.b $8F,$00,$5D,$77,$AF,$BE,$26,$1E 
  CLSID_MsftDiscRecorder2: 
    Data.l $2735412D
    Data.w $7F64,$5B0F 
    Data.b $8F,$00,$5D,$77,$AF,$BE,$26,$1E
  CLSID_MsftDiscFormat2Data:
    Data.l $2735412A
    Data.w $7F64,$5B0F
    Data.b $8F,$00,$5D,$77,$AF,$BE,$26,$1E
  CLSID_MsftDiscFormat2Erase:
    Data.l $2735412B
    Data.w $7F64,$5B0F
    Data.b $8F,$00,$5D,$77,$AF,$BE,$26,$1E
  CLSID_MsftDiscFormat2RawCD:
    Data.l $27354128
    Data.w $7F64,$5B0F
    Data.b $8F,$00,$5D,$77,$AF,$BE,$26,$1E
  CLSID_MsftDiscFormat2TrackAtOnce:
    Data.l $27354129
    Data.w $7F64,$5B0F
    Data.b $8F,$00,$5D,$77,$AF,$BE,$26,$1E
  CLSID_MsftWriteEngine2:
    Data.l $2735412C
    Data.w $7F64,$5B0F
    Data.b $8F,$00,$5D,$77,$AF,$BE,$26,$1E
  CLSID_MsftStreamConcatenate:
    Data.l $27354125
    Data.w $7F64,$5B0F
    Data.b $8F,$00,$5D,$77,$AF,$BE,$26,$1E
  CLSID_MsftStreamInterleave:
    Data.l $27354124
    Data.w $7F64,$5B0F
    Data.b $8F,$00,$5D,$77,$AF,$BE,$26,$1E
  CLSID_MsftStreamPrng001:
    Data.l $27354126
    Data.w $7F64,$5B0F
    Data.b $8F,$00,$5D,$77,$AF,$BE,$26,$1E
  CLSID_IMAPI2:
    Data.l $2735412F
    Data.w $7F64,$5B0F
    Data.b $8F,$0,$5D,$77,$AF,$BE,$26,$1E
  CLSID_IMAPI2FS:
    Data.l $2C941FD0
    Data.w $975B,$59BE
    Data.b $A9,$60,$9A,$2A,$26,$28,$53,$A5
  IID_IBootOptions:
    Data.l $2C941FD4 
    Data.w $975B,$59BE 
    Data.b $A9,$60,$9A,$2A,$26,$28,$53,$A5 
  IID_IFileSystemImage: 
    Data.l $2C941FE1 
    Data.w $975B,$59BE 
    Data.b $A9,$60,$9A,$2A,$26,$28,$53,$A5
  IID_IFileSystemImageResult:
    Data.l $2C941FD8 
    Data.w $975B,$59BE 
    Data.b $A9,$60,$9A,$2A,$26,$28,$53,$A5
  IID_IDiscMaster2:
    Data.l $27354130 
    Data.w $7F64,$5B0F 
    Data.b $8F,$00,$5D,$77,$AF,$BE,$26,$1E 
  IID_IDiscRecorder2: 
    Data.l $27354133 
    Data.w $7F64,$5B0F 
    Data.b $8F,$00,$5D,$77,$AF,$BE,$26,$1E
  IID_IDiscFormat2Data:
    Data.l $27354153 
    Data.w $9F64,$5B0F 
    Data.b $8F,$00,$5D,$77,$AF,$BE,$26,$1E
  IID_IDiscFormat2Erase:
    Data.l $27354156
    Data.w $8F64,$5B0F
    Data.b $8F,$00,$5D,$77,$AF,$BE,$26,$1E
  IID_IWriteEngine2EventArgs:
    Data.l $27354136
    Data.w $7F64,$5B0F
    Data.b $8F,$0,$5D,$77,$AF,$BE,$26,$1E
  IID_IDiscFormat2DataEventArgs:
    Data.l $2735413D
    Data.w $7F64,$5B0F
    Data.b $8F,$0,$5D,$77,$AF,$BE,$26,$1E
  IID_IDiscFormat2TrackAtOnceEventArgs:
    Data.l $27354140
    Data.w $7F64,$5B0F
    Data.b $8F,$0,$5D,$77,$AF,$BE,$26,$1E
  IID_IDiscFormat2RawCDEventArgs:
    Data.l $27354143
    Data.w $7F64,$5B0F
    Data.b $8F,$0,$5D,$77,$AF,$BE,$26,$1E
  IID_IWriteSpeedDescriptor:
    Data.l $27354144
    Data.w $7F64,$5B0F
    Data.b $8F,$0,$5D,$77,$AF,$BE,$26,$1E
  IID_DDiscMaster2Events:
    Data.l $27354131
    Data.w $7F64,$5B0F
    Data.b $8F,$0,$5D,$77,$AF,$BE,$26,$1E
  IID_DWriteEngine2Events:
    Data.l $27354137
    Data.w $7F64,$5B0F
    Data.b $8F,$0,$5D,$77,$AF,$BE,$26,$1E
  IID_DDiscFormat2EraseEvents:
    Data.l $2735413A
    Data.w $7F64,$5B0F
    Data.b $8F,$0,$5D,$77,$AF,$BE,$26,$1E
  IID_DDiscFormat2DataEvents:
    Data.l $2735413C
    Data.w $7F64,$5B0F
    Data.b $8F,$0,$5D,$77,$AF,$BE,$26,$1E
  IID_DDiscFormat2TrackAtOnceEvents:
    Data.l $2735413F
    Data.w $7F64,$5B0F
    Data.b $8F,$0,$5D,$77,$AF,$BE,$26,$1E
  IID_DDiscFormat2RawCDEvents:
    Data.l $27354142
    Data.w $7F64,$5B0F
    Data.b $8F,$0,$5D,$77,$AF,$BE,$26,$1E
  IID_IDiscRecorder2Ex:
    Data.l $27354132
    Data.w $7F64,$5B0F
    Data.b $8F,$0,$5D,$77,$AF,$BE,$26,$1E
  IID_IWriteEngine2:
    Data.l $27354135
    Data.w $7F64,$5B0F
    Data.b $8F,$0,$5D,$77,$AF,$BE,$26,$1E
  IID_IDiscFormat2:
    Data.l $27354152
    Data.w $8F64,$5B0F
    Data.b $8F,$0,$5D,$77,$AF,$BE,$26,$1E
  IID_IDiscFormat2TrackAtOnce:
    Data.l $27354154
    Data.w $8F64,$5B0F
    Data.b $8F,$0,$5D,$77,$AF,$BE,$26,$1E
  IID_IDiscFormat2RawCD:
    Data.l $27354155
    Data.w $8F64,$5B0F
    Data.b $8F,$0,$5D,$77,$AF,$BE,$26,$1E
  IID_IMultisessionSequential:
    Data.l $27354151
    Data.w $7F64,$5B0F
    Data.b $8F,$0,$5D,$77,$AF,$BE,$26,$1E
  IID_IMultisession:
    Data.l $27354150
    Data.w $7F64,$5B0F
    Data.b $8F,$0,$5D,$77,$AF,$BE,$26,$1E
  IID_IProgressItems:
    Data.l $2C941FD7
    Data.w $975B,$59BE
    Data.b $A9,$60,$9A,$2A,$26,$28,$53,$A5
  IID_IProgressItem:
    Data.l $2C941FD5
    Data.w $975B,$59BE
    Data.b $A9,$60,$9A,$2A,$26,$28,$53,$A5
  IID_IStreamConcatenate:
    Data.l $27354146
    Data.w $7F64,$5B0F
    Data.b $8F,$0,$5D,$77,$AF,$BE,$26,$1E
  IID_IStreamInterleave:
    Data.l $27354147
    Data.w $7F64,$5B0F
    Data.b $8F,$0,$5D,$77,$AF,$BE,$26,$1E
  IID_IStreamPseudoRandomBased:
    Data.l $27354145
    Data.w $7F64,$5B0F
    Data.b $8F,$0,$5D,$77,$AF,$BE,$26,$1E
EndDataSection