Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: IMAPI MsftDiscMaster MsftDiscRecorder MsftDiscFormat2Data 2.1 IMAPI2.1 IMAPI2.MsftDiscMaster2.1 IMAPI2.MsftDiscRecorder2.1 IMAPI2.MsftDiscFormat2Data.1
; 20101219.Detlev Dalitz ; Tested on Win XP SP3 with IMAPI2.1 objDiscMaster = ObjectCreate ("IMAPI2.MsftDiscMaster2.1") conIMAPI2 = ObjectConstantsGet (objDiscMaster) ;arrIMAPI2 = ObjectConstToArray (conIMAPI2) If !objDiscMaster.IsSupportedEnvironment objDiscMaster = 0 strMsgTitle = "Terminated|" : IntControl (1004, 0, 0, 0, 0) strMsgText = "IMAPI is not running in an environment with optical devices and permission to access them." Terminate (@TRUE, strMsgTitle, strMsgText) EndIf strMsgTitle = "MsftDiscRecorder Info" strMsgText = "Current number of optical devices in the system = " : objDiscMaster.Count ForEach strID In objDiscMaster strMsgText = strMsgText : @LF : @LF : "Device ID = " : strID objRecorder = ObjectCreate ("IMAPI2.MsftDiscRecorder2.1") intLastEM = ErrorMode (@OFF) LastError () objRecorder.InitializeDiscRecorder(strID) intLastError = LastError () ErrorMode (intLastEM) If intLastError > 0 objRecorder = 0 strMsgText = strMsgText : @LF : "Device cannot be initialized." Continue EndIf strListVPN = "" ForEach strVPN In objRecorder.VolumePathNames ; Drive letters and NTFS mount points to access the recorder. strListVPN = ItemInsert (strVPN, -1, strListVPN, "|") strMsgText = strMsgText : @LF : "VolumePathName = " : strVPN Next objDataWriter = CreateObject ("IMAPI2.MsftDiscFormat2Data.1") intLastEM = ErrorMode (@OFF) LastError () objDataWriter.Recorder = objRecorder intLastError = LastError () ErrorMode (intLastEM) If intLastError > 0 strMsgText = strMsgText : @LF : "Device cannot be used as Data Writer." Continue EndIf If objDataWriter.IsRecorderSupported(objRecorder) strMsgText = strMsgText : @LF : "Recorder is supported." Else strMsgText = strMsgText : @LF : "Recorder is not supported." EndIf If objDataWriter.IsRecorderSupported(objRecorder) Message ("User intervention needed", "If available, insert a recording media into this device" : @LF : @LF : "Device ID = " : strId : @LF : "VolumePathName = " : strListVPN : @LF : @LF : "Press OK to continue.") If objDataWriter.IsCurrentMediaSupported(objRecorder) strMsgText = strMsgText : @LF : "Current media is supported." ; Check CurrentMediaStatus possibilities. Each status is associated with a bit and some combinations are legal. intMediaStatus = 0 For intCheck = 1 To 10 intLastEM = ErrorMode (@OFF) LastError () intMediaStatus = objDataWriter.CurrentMediaStatus intLastError = LastError () ErrorMode (intLastEM) If intLastError == 0 Then Break Display (3, "User intervention needed", "Please wait for receiving current media status from" : @LF : "Device ID = " : strID : @LF : "VolumePathName = " : strListVPN) Next If intLastError != 0 Message ("Note", "Cannot get media status from " : @LF : "Device ID = " : strID : @LF : "VolumePathName = " : strListVPN) Continue EndIf strMediaStatus = "" If intMediaStatus == 0 strMediaStatus = "Media state = UNKNOWN" Else If intMediaStatus & conIMAPI2.IMAPI_FORMAT2_DATA_MEDIA_STATE_UNSUPPORTED_MASK ;64512 strMediaStatus = strMediaStatus : @LF : "Media state = UNSUPPORTED_MASK" EndIf If intMediaStatus & conIMAPI2.IMAPI_FORMAT2_DATA_MEDIA_STATE_UNSUPPORTED_MEDIA ;32768 strMediaStatus = strMediaStatus : @LF : "Media state = UNSUPPORTED_MEDIA" EndIf If intMediaStatus & conIMAPI2.IMAPI_FORMAT2_DATA_MEDIA_STATE_FINALIZED ;16384 strMediaStatus = strMediaStatus : @LF : "Media state = FINALIZED" EndIf If intMediaStatus & conIMAPI2.IMAPI_FORMAT2_DATA_MEDIA_STATE_WRITE_PROTECTED ;8192 strMediaStatus = strMediaStatus : @LF : "Media state = WRITE_PROTECTED" EndIf If intMediaStatus & conIMAPI2.IMAPI_FORMAT2_DATA_MEDIA_STATE_NON_EMPTY_SESSION ;4096 strMediaStatus = strMediaStatus : @LF : "Media state = NON_EMPTY_SESSION" EndIf If intMediaStatus & conIMAPI2.IMAPI_FORMAT2_DATA_MEDIA_STATE_ERASE_REQUIRED ;2048 strMediaStatus = strMediaStatus : @LF : "Media state = ERASE_REQUIRED" EndIf If intMediaStatus & conIMAPI2.IMAPI_FORMAT2_DATA_MEDIA_STATE_DAMAGED ;1024 strMediaStatus = strMediaStatus : @LF : "Media state = DAMAGED" EndIf If intMediaStatus & conIMAPI2.IMAPI_FORMAT2_DATA_MEDIA_STATE_INFORMATIONAL_MASK ;15 strMediaStatus = strMediaStatus : @LF : "Media state = INFORMATIONAL_MASK" EndIf If intMediaStatus & conIMAPI2.IMAPI_FORMAT2_DATA_MEDIA_STATE_FINAL_SESSION ;8 strMediaStatus = strMediaStatus : @LF : "Media state = FINAL_SESSION" EndIf If intMediaStatus & conIMAPI2.IMAPI_FORMAT2_DATA_MEDIA_STATE_APPENDABLE ;4 strMediaStatus = strMediaStatus : @LF : "Media state = APPENDABLE" EndIf If intMediaStatus & conIMAPI2.IMAPI_FORMAT2_DATA_MEDIA_STATE_BLANK ;2 strMediaStatus = strMediaStatus : @LF : "Media state = BLANK" EndIf If intMediaStatus & conIMAPI2.IMAPI_FORMAT2_DATA_MEDIA_STATE_OVERWRITE_ONLY ;1 ; ??? strMediaStatus = strMediaStatus : @LF : "Media state = OVERWRITE_ONLY" EndIf If intMediaStatus & conIMAPI2.IMAPI_FORMAT2_DATA_MEDIA_STATE_RANDOMLY_WRITABLE ;1 ; ??? strMediaStatus = strMediaStatus : @LF : "Media state = RANDOMLY_WRITABLE" EndIf EndIf strMsgText = strMsgText : strMediaStatus strMediaType = ItemExtract (1 + objDataWriter.CurrentPhysicalMediaType, "UNKNOWN,CDROM,CDR,CDRW,DVDROM,DVDRAM,DVDPLUSR,DVDPLUSRW,DVDPLUSR_DUALLAYER,DVDDASHR,DVDDASHRW,DVDDASHR_DUALLAYER,DISK,DVDPLUSRW_DUALLAYER,HDDVDROM,HDDVDR,HDDVDRAM,BDROM,BDR,BDRE", ",") strMsgText = strMsgText : @LF : "Current Media Type = " : strMediaType EndIf Else strMsgText = strMsgText : @LF : "Current media is not supported." EndIf objDataWriter = 0 objRecorder = 0 Next objDiscMaster = 0 Pause (strMsgTitle, strMsgText) ClipPut (strMsgTitle : @CRLF : @CRLF : StrReplace (strMsgText, @LF, @CRLF) : @CRLF) :CANCEL Exit
Article ID: W18079
Filename: MsftDiscRecorder Info.txt
File Created: 2010:12:20:09:42:32
Last Updated: 2010:12:20:09:42:32