ADODB.Stream from file ? [for burning with pb]
Posted: Wed Jul 04, 2007 7:05 pm
my pb skeleton ...
any hints how to handle the
object\open(...)
object\LoadFromFile(...)
I would like to translate this (vbs) vista script in pb4 ...
' This script burns a boot image and 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 FsiFileSystemUDF = 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
Dim bootFile ' Path and filename of boot image
index = 0 ' first drive on the system
path = "c:\burn"
bootFile = "c:\burn\freedos.ima"
' Create a DiscMaster2 object to connect to CD/DVD 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 )
' -------- Adding Boot Image Code -----
Dim bootOptions
WScript.Echo "Creating BootOptions"
SET bootOptions = WScript.CreateObject("IMAPI2FS.BootOptions")
bootOptions.Manufacturer = "Microsoft"
bootOptions.PlatformId = 0 ' x86 family processor
bootOptions.Emulation = 0 ' EmulationType.EmulationNone
' Need a stream for the boot image file
Const adFileTypeBinary = 1
DIM bootStream
Set bootStream = CreateObject("ADODB.Stream")
WScript.Echo "Creating IStream for file " + bootFile
bootStream.Open
bootStream.Type = adFileTypeBinary
bootStream.LoadFromFile bootFile
bootOptions.AssignBootImage(bootStream)
' Create disc file system image (ISO9660 in this example)
Dim FSI
SET FSI = WScript.CreateObject("IMAPI2FS.MsftFileSystemImage")
FSI.FreeMediaBlocks = 0 ' Enables larger-than-CD image
FSI.FileSystemsToCreate = FsiFileSystemISO9660
' Add the boot directory and its contents to the file system
FSI.BootImageOptions = bootOptions
' Add the content directory and files to the file system
FSI.root.AddTree path, FALSE
Dim result
Set result = FSI.CreateResultImage()
stream = result.ImageStream
' Create and write stream to disc using the specified recorder.
Dim dataWriter
Set dataWriter = CreateObject("IMAPI2.MsftDiscFormat2Data")
dataWriter.recorder = Recorder
dataWriter.ClientName = "IMAPIv2 TEST"
dataWriter.write(stream)
WScript.Echo "----- Finished writing content -----"
Main = 0
End Function
Code: Select all
;ADODB.Stream
Interface _Stream Extends IDispatch
get_Size(a)
get_EOS(a)
get_Position(a)
put_Position(a)
get_Type(a)
put_Type(a)
get_LineSeparator(a)
put_LineSeparator(a)
get_State(a)
get_Mode(a)
put_Mode(a)
get_Charset(a)
put_Charset(a)
Read(a,b)
Open(a,b,c,d,e)
Close()
SkipLine()
Write(a,b,c,d)
SetEOS()
CopyTo(a,b)
Flush()
SaveToFile(a,b)
LoadFromFile(a)
ReadText(a,b)
WriteText(a,b)
Cancel()
EndInterface
CoInitialize_(0)
If CoCreateInstance_(?CLSID_Stream,0,1,?IID__Stream,@object._Stream) = 0
;object\open(???)
;object\LoadFromFile(???)
object\release()
EndIf
CoUninitialize_()
End
DataSection
CLSID_Stream:
Data.l $00000566
Data.w $0000,$0010
Data.b $80,$00,$00,$AA,$00,$6D,$2E,$A4
IID__Stream:
Data.l $00000565
Data.w $0000,$0010
Data.b $80,$00,$00,$AA,$00,$6D,$2E,$A4
EndDataSectionany hints how to handle the
object\open(...)
object\LoadFromFile(...)
I would like to translate this (vbs) vista script in pb4 ...
' This script burns a boot image and 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 FsiFileSystemUDF = 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
Dim bootFile ' Path and filename of boot image
index = 0 ' first drive on the system
path = "c:\burn"
bootFile = "c:\burn\freedos.ima"
' Create a DiscMaster2 object to connect to CD/DVD 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 )
' -------- Adding Boot Image Code -----
Dim bootOptions
WScript.Echo "Creating BootOptions"
SET bootOptions = WScript.CreateObject("IMAPI2FS.BootOptions")
bootOptions.Manufacturer = "Microsoft"
bootOptions.PlatformId = 0 ' x86 family processor
bootOptions.Emulation = 0 ' EmulationType.EmulationNone
' Need a stream for the boot image file
Const adFileTypeBinary = 1
DIM bootStream
Set bootStream = CreateObject("ADODB.Stream")
WScript.Echo "Creating IStream for file " + bootFile
bootStream.Open
bootStream.Type = adFileTypeBinary
bootStream.LoadFromFile bootFile
bootOptions.AssignBootImage(bootStream)
' Create disc file system image (ISO9660 in this example)
Dim FSI
SET FSI = WScript.CreateObject("IMAPI2FS.MsftFileSystemImage")
FSI.FreeMediaBlocks = 0 ' Enables larger-than-CD image
FSI.FileSystemsToCreate = FsiFileSystemISO9660
' Add the boot directory and its contents to the file system
FSI.BootImageOptions = bootOptions
' Add the content directory and files to the file system
FSI.root.AddTree path, FALSE
Dim result
Set result = FSI.CreateResultImage()
stream = result.ImageStream
' Create and write stream to disc using the specified recorder.
Dim dataWriter
Set dataWriter = CreateObject("IMAPI2.MsftDiscFormat2Data")
dataWriter.recorder = Recorder
dataWriter.ClientName = "IMAPIv2 TEST"
dataWriter.write(stream)
WScript.Echo "----- Finished writing content -----"
Main = 0
End Function