Continuing on from my first post Creating SDI Images using VBScript I am going to look at a more complete example here. I've also attached a working script.MakeSDI.vbs (4.76 KB)
Previously we saw that you can create a new SDI image doing the following:
Set oSDIFile = oSDI.CreateImage(sImage, SDICREATENEW)
Now this isn't really all that useful because without a disk blob inside the SDI file you cannot partition and format the SDI file.
Now I'll leave it to someone more knowledgable than myself to explain exactly what a DISK blog is but you create one by using oSDIFile.Blobs.Allocate DISK, nLo, nHi. The signature for Allocate is:
Sub Allocate(ByVal ldwType As Long, ByVal ldwSizeLowPart As Long, [ByVal ldwSizeHighPart As Long])
Confused?? I was but if you take a look in SDIMgr.swf from the Windows XP Embedded Tools you'll be able to extract just the bits you need. I've provided them below and don't forget the example script that is attached.
Sub
CreateDisk(sSize)
Dim nSize 'size in MB
Dim sHex 'size as Hex
Dim nLo 'Low DWORD
Dim nHi 'High DWORD
Dim oBlob 'DISK Blob
'Get the size in MB
nSize = GetSizeInMB(sSize)
'Convert to hex
sHex = Right("00000000" & Hex(nSize), 8)
'Form the Low DWORD
nLo = CLng("&h" & Right(sHex, 3) & "00000")
nHi = CLng("&h" & Left(sHex, 5))
'Create a DISK Blog
oSDIFile.Blobs.Allocate DISK, nLo, nHi
Set oBlob = FindBlob(oSDIFile)
oBlob.Attribute = 0
End Sub
Function
GetSizeInMB(sData)
Dim sTemp : sTemp = Trim(sData)
Dim lTemp : lTemp = CLng(sTemp)
GetSizeInMB = lTemp \ 1048576
End Function
Function FindBlob(oSDIFile)
Dim oBlob
Set FindBlob = Nothing
For Each oBlob In oSDIFile.Blobs
If oBlob.Type = DISK Then Set FindBlob = oBlob : Exit Function
Next
End Function
Enjoy!