Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Using automation to burn a CD
Message
De
21/09/2011 16:31:24
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Novell 4.x
Database:
Visual FoxPro
Divers
Thread ID:
01214030
Message ID:
01524199
Vues:
61
>This code is VB code. If the createobject line will work for you, translating that code into VFP syntax seems pretty straightforward.

It seems pretty straightforward but it isn't

The Stream returned by result.ImageStream is not treated correctly by vfp, hence dataWriter.write(Stream) produces an error

The only way to have the burning run ok is to use the vb script
>>    ' Create an image from the file system
>>    Dim result
>>    Set result = FSI.CreateResultImage()
>>    Stream = result.ImageStream


>>    dataWriter.write(Stream)
>>I found this message by Tore indication.
>>
>>But I notice the below has "dim".
>>
>>Can anyony confirm it's a VFP function ?
>>
>>
>>Moises
>>
>>
>>
>>>use IMAPI Please check the link and sample code below perhaps you can convert that into VFP since its a COM
>>>http://msdn2.microsoft.com/en-us/library/aa364817.aspx
>>>
>>>
>>>
>>>
>>>' This script burns data files to disc in a single session 
>>>' using files from a single directory tree.
>>> 
>>>' Copyright (C) Microsoft Corp. 2006
>>>
>>>Option Explicit
>>>
>>>' *** CD/DVD disc file system types
>>>Const FsiFileSystemISO9660 = 1
>>>Const FsiFileSystemJoliet  = 2
>>>Const FsiFileSystemUDF102  = 4
>>>
>>>WScript.Quit(Main)
>>>
>>>Function Main
>>>    Dim Index                ' Index to recording drive.
>>>    Dim Recorder             ' Recorder object
>>>    Dim Path                 ' Directory of files to burn
>>>    Dim Stream               ' Data stream for burning device
>>>    
>>>    Index = 1                ' Second drive on the system
>>>    Path = "g:\BurnDir"      ' Files to transfer to disc
>>>
>>>    ' Create a DiscMaster2 object to connect to optical drives.
>>>    Dim g_DiscMaster
>>>    Set g_DiscMaster = WScript.CreateObject("IMAPI2.MsftDiscMaster2")
>>>
>>>    ' Create a DiscRecorder object for the specified burning device.
>>>    Dim uniqueId
>>>    set recorder = WScript.CreateObject("IMAPI2.MsftDiscRecorder2")
>>>    uniqueId = g_DiscMaster.Item(index)
>>>    recorder.InitializeDiscRecorder( uniqueId )
>>>
>>>    ' Create an image stream for a specified directory.
>>>    Dim FSI                  ' Disc file system
>>>    Dim Dir                  ' Root directory of the disc file system
>>>    Dim dataWriter    
>>>        
>>>    ' Create a new file system image and retrieve root directory
>>>    Set FSI = CreateObject("IMAPI2FS.MsftFileSystemImage")
>>>    Set Dir = FSI.Root
>>>
>>>    'Create the new disc format and set the recorder
>>>    Set dataWriter = CreateObject ("IMAPI2.MsftDiscFormat2Data")
>>>    dataWriter.recorder = Recorder
>>>    dataWriter.ClientName = "IMAPIv2 TEST"
>>>
>>>    FSI.FreeMediaBlocks = datawriter.FreeSectorsOnMedia
>>>    FSI.FileSystemsToCreate = FsiFileSystemISO9660
>>>        
>>>    ' Add the directory and its contents to the file system 
>>>    Dir.AddTree Path, false
>>>        
>>>    ' Create an image from the file system
>>>    Dim result
>>>    Set result = FSI.CreateResultImage()
>>>    Stream = result.ImageStream
>>>    
>>>    ' Write stream to disc using the specified recorder.
>>>    WScript.Echo "Writing content to disc..."
>>>    dataWriter.write(Stream)
>>>
>>>    WScript.Echo "----- Finished writing content -----"
>>>    Main = 0
>>>End Function
>>>
>>>
>>>
Gregory
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform