Is there a relatively straightforward way to finalize a CD or DVD in C# or PowerShell?

后端 未结 2 1396
耶瑟儿~
耶瑟儿~ 2020-12-29 10:50

First, some clarification of terms. By finalize, I don\'t mean closing a session; I mean writing a lead-out to a CD or DVD in such a way that information c

2条回答
  •  梦毁少年i
    2020-12-29 11:38

    Set the ForceMediaToBeClosed flag on the IMAPI2.MsftDiscFormat2Data object and write out the disc with the close flag enabled.

    • If you already know its your last session, set the flag, add your data to write and then write it out and it will close.
    • If you have already written your last session, import the last session, set the flag and write to close.

    Approach is described here: https://social.msdn.microsoft.com/Forums/en-US/ce1ff136-39a1-4442-bc5c-61c119b6f4f2/finalize-question?forum=windowsopticalplatform#2e968a94-7347-4d94-9332-00fe7cd0ba89

    Below is a link to a nice Powershell burning script, all you'd have to do is update Out-CD with a new param to set $DiscFormatData.ForceMediaToBeClosed = true when you are ready for your closing write.

    Link: https://www.adamtheautomator.com/use-powershell-to-automate-burning-cds/

    FYI:

    # this fetches all the properties (as you probably already know)
    $DiscFormatData  = New-Object -com IMAPI2.MsftDiscFormat2Data ;
    $DiscFormatData | Get-Member ;
    

提交回复
热议问题