Page 1 of 1

folder to iso (vista , xp/sp2 + KB932716 !)

Posted: Fri Nov 23, 2007 8:42 pm
by bingo
for testing edit the line:

isofile.s = "c:\tmp\mein.iso"
foldertoiso.s = "c:\temp\"
:D

Code: Select all

Import "shlwapi.lib" 
SHCreateStreamOnFileEx(pszFile.p-unicode,grfMode.l,dwAttributes.l,fCreate.b,pstmTemplate.l,ppstm.l); 
EndImport 

Interface IBootOptions ; Boot options 
  QueryInterface(riid.l,ppvObj.l) 
  AddRef() 
  Release() 
  GetTypeInfoCount(pctinfo.l) 
  GetTypeInfo(itinfo.l,lcid.l,pptinfo.l) 
  GetIDsOfNames(riid.l,rgszNames.l,cNames.l,lcid.l,rgdispid.l) 
  Invoke(dispidMember.l,riid.l,lcid.l,wFlags.l,pdispparams.l,pvarResult.l,pexcepinfo.l,puArgErr.l) 
  get_BootImage(dispidMember.l) 
  get_Manufacturer(dispidMember.l) 
  put_Manufacturer(dispidMember.p-bstr) 
  get_PlatformId(dispidMember.l) 
  put_PlatformId(dispidMember.l) 
  get_Emulation(dispidMember.l) 
  put_Emulation(dispidMember.l) 
  get_ImageSize(dispidMember.l) 
  AssignBootImage(newVal.l) 
EndInterface 

Interface IFileSystemImage ; File system image 
  QueryInterface(riid.l,ppvObj.l) 
  AddRef() 
  Release() 
  GetTypeInfoCount(pctinfo.l) 
  GetTypeInfo(itinfo.l,lcid.l,pptinfo.l) 
  GetIDsOfNames(riid.l,rgszNames.l,cNames.l,lcid.l,rgdispid.l) 
  Invoke(dispidMember.l,riid.l,lcid.l,wFlags.l,pdispparams.l,pvarResult.l,pexcepinfo.l,puArgErr.l) 
  get_Root(dispidMember.l) 
  get_SessionStartBlock(dispidMember.l) 
  put_SessionStartBlock(dispidMember.l) 
  get_FreeMediaBlocks(dispidMember.l) 
  put_FreeMediaBlocks(dispidMember.l) 
  SetMaxMediaBlocksFromDevice(discRecorder.l) 
  get_UsedBlocks(discRecorder.l) 
  get_VolumeName(discRecorder.l) 
  put_VolumeName(discRecorder.p-bstr) 
  get_ImportedVolumeName(discRecorder.l) 
  get_BootImageOptions(discRecorder.l) 
  put_BootImageOptions(discRecorder.l) 
  get_FileCount(discRecorder.l) 
  get_DirectoryCount(discRecorder.l) 
  get_WorkingDirectory(discRecorder.l) 
  put_WorkingDirectory(discRecorder.p-bstr) 
  get_ChangePoint(discRecorder.l) 
  get_StrictFileSystemCompliance(discRecorder.l) 
  put_StrictFileSystemCompliance(discRecorder.w) 
  get_UseRestrictedCharacterSet(discRecorder.l) 
  put_UseRestrictedCharacterSet(discRecorder.w) 
  get_FileSystemsToCreate(discRecorder.l) 
  put_FileSystemsToCreate(discRecorder.l) 
  get_FileSystemsSupported(discRecorder.l) 
  put_UDFRevision(discRecorder.l) 
  get_UDFRevision(discRecorder.l) 
  get_UDFRevisionsSupported(discRecorder.l) 
  ChooseImageDefaults(discRecorder.l) 
  ChooseImageDefaultsForMediaType(value.l) 
  put_ISO9660InterchangeLevel(value.l) 
  get_ISO9660InterchangeLevel(value.l) 
  get_ISO9660InterchangeLevelsSupported(value.l) 
  CreateResultImage(a.l) 
  Exists(FullPath.p-bstr) 
  CalculateDiscIdentifier() 
  IdentifyFileSystemsOnDisc(discRecorder.l) 
  GetDefaultFileSystemForImport(fileSystems.l) 
  ImportFileSystem() 
  ImportSpecificFileSystem(fileSystemToUse.l) 
  RollbackToChangePoint(ChangePoint.l) 
  LockInChangePoint() 
  CreateDirectoryItem(Name.p-bstr) 
  CreateFileItem(Name.p-bstr) 
  get_VolumeNameUDF(Name.l) 
  get_VolumeNameJoliet(Name.l) 
  get_VolumeNameISO9660(Name.l) 
  get_StageFiles(Name.l) 
  put_StageFiles(Name.w) 
  get_MultisessionInterfaces(Name.l) 
  put_MultisessionInterfaces(Name.l) 
EndInterface 

Interface IFileSystemImageResult ; FileSystemImage result stream 
  QueryInterface(riid.l,ppvObj.l) 
  AddRef() 
  Release() 
  GetTypeInfoCount(pctinfo.l) 
  GetTypeInfo(itinfo.l,lcid.l,pptinfo.l) 
  GetIDsOfNames(riid.l,rgszNames.l,cNames.l,lcid.l,rgdispid.l) 
  Invoke(dispidMember.l,riid.l,lcid.l,wFlags.l,pdispparams.l,pvarResult.l,pexcepinfo.l,puArgErr.l) 
  get_ImageStream(dispidMember.l) 
  get_ProgressItems(dispidMember.l) 
  get_TotalBlocks(dispidMember.l) 
  get_BlockSize(dispidMember.l) 
  get_DiscId(dispidMember.l) 
EndInterface 

Interface IFsiDirectoryItem ; FileSystemImage directory item 
  QueryInterface(riid.l,ppvObj.l) 
  AddRef() 
  Release() 
  GetTypeInfoCount(pctinfo.l) 
  GetTypeInfo(itinfo.l,lcid.l,pptinfo.l) 
  GetIDsOfNames(riid.l,rgszNames.l,cNames.l,lcid.l,rgdispid.l) 
  Invoke(dispidMember.l,riid.l,lcid.l,wFlags.l,pdispparams.l,pvarResult.l,pexcepinfo.l,puArgErr.l) 
  get_Name(dispidMember.l) 
  get_FullPath(dispidMember.l) 
  get_CreationTime(dispidMember.l) 
  put_CreationTime(dispidMember.d) 
  get_LastAccessedTime(dispidMember.l) 
  put_LastAccessedTime(dispidMember.d) 
  get_LastModifiedTime(dispidMember.l) 
  put_LastModifiedTime(dispidMember.d) 
  get_IsHidden(dispidMember.l) 
  put_IsHidden(dispidMember.w) 
  FileSystemName(fileSystem.l) 
  FileSystemPath(fileSystem.l) 
  get__NewEnum(fileSystem.l) 
  get_Item(path.p-bstr) 
  get_Count(path.l) 
  get_EnumFsiItems(path.l) 
  AddDirectory(path.p-bstr) 
  AddFile(path.p-bstr,fileData.l) 
  AddTree(sourceDirectory.p-bstr,includeBaseDirectory.w) 
  Add(Item.l) 
  Remove(path.p-bstr) 
  RemoveTree(path.p-bstr) 
EndInterface 

Structure STATSTG  
pwcsName.l 
type.l 
cbSize.q 
mtime.FILETIME 
ctime.FILETIME 
atime.FILETIME 
grfMode.f 
grfLocksSupported.l 
clsid.GUID 
grfStateBits.l 
reserved.l 
EndStructure 

Procedure.l Ansi2Uni(ansi.s) 
SHStrDup_(@ansi,@memziel) 
ProcedureReturn memziel 
EndProcedure 

#STGM_WRITE = 1 
#STGM_CREATE = $1000 
#STATFLAG_NONAME = 0 

#FsiFileSystemNone = 0 
#FsiFileSystemISO9660 = 1 
#FsiFileSystemJoliet = 2 
#FsiFileSystemUDF = 4 
#FsiFileSystemUnknown = 1073741824 

isostream.IStream 
datastream.IStream 

isofile.s = "c:\tmp\mein.iso" 
foldertoiso.s = "c:\temp\" 

CreateStreamOnHGlobal_(0,#True,@datastream) 
SHCreateStreamOnFileEx(isofile ,#STGM_WRITE|#STGM_CREATE,0,0,0,@isoStream) 

CoInitialize_(0) 
If CoCreateInstance_(?CLSID_BootOptions,0,1,?IID_IBootOptions,@object_boot.IBootOptions) = 0 
object_boot\put_Manufacturer("Microsoft") 
object_boot\put_PlatformId(0) ;x86 family processor 
object_boot\put_Emulation(0)  ;EmulationType.EmulationNone 
;... 

If CoCreateInstance_(?CLSID_FileSystemImage,0,1,?IID_IFileSystemImage,@object_fsimage.IFileSystemImage) = 0 

object_fsimage\put_FreeMediaBlocks(0) ;Enables larger-than-CD image 
object_fsimage\put_FileSystemsToCreate(#FsiFileSystemJoliet) 
object_fsimage\put_VolumeName("my iso") 
object_fsimage\put_BootImageOptions(object_boot.IBootOptions) 

object_fsimage\get_root(@object_fsidir.IFsiDirectoryItem) 

Debug object_fsidir\AddTree(foldertoiso,#VARIANT_TRUE) 
Debug object_fsidir\get_count(@dirinroot.l) 
Debug dirinroot ;1 

object_fsimage\CreateResultImage(@result.IFileSystemImageResult) 

result\get_ImageStream(@datastream) 

dataStream\Stat(st.STATSTG,#STATFLAG_NONAME) 
Debug "size: " + Str(st\cbSize) + " bytes" 

ret1.q 
ret2.q 

datastream\copyto(isostream,st\cbSize,@ret1,@ret2) 

Debug ret1 
Debug ret2 

object_fsimage\release() 
EndIf 

object_boot\Release() 
EndIf 

object_fsidir\release() 
isostream\release() 
datastream\release() 

CoUninitialize_() 

End 

DataSection 
CLSID_FileSystemImage: 
Data.l $2C941FC5 
Data.w $975B,$59BE 
Data.b $A9,$60,$9A,$2A,$26,$28,$53,$A5 
IID_IFileSystemImage: 
Data.l $2C941FE1 
Data.w $975B,$59BE 
Data.b $A9,$60,$9A,$2A,$26,$28,$53,$A5 
CLSID_BootOptions: 
Data.l $2C941FCE 
Data.w $975B,$59BE 
Data.b $A9,$60,$9A,$2A,$26,$28,$53,$A5 
IID_IBootOptions: 
Data.l $2C941FD4 
Data.w $975B,$59BE 
Data.b $A9,$60,$9A,$2A,$26,$28,$53,$A5 
EndDataSection

Posted: Sat Nov 24, 2007 2:19 am
by GeoTrail
That's pretty cool. Thanks for the code.
Could that work for compressed ISO (isz) files as well?

Posted: Sat Nov 24, 2007 3:10 am
by Mistrel
Compressed iso (isz) is an open format created by the makers of Ultra ISO and is not supported natively by the Windows OS.

http://www.ezbsystems.com/isz/iszspec.txt

Posted: Sat Nov 24, 2007 7:57 pm
by fsw
I read somewhere that if you create an ISO and use Vista build-in stuff for that the resulting ISO can't be read on Linux.
Is this true?

Don't have Vista myself, so I can't test it...

Posted: Sat Nov 24, 2007 8:01 pm
by Kwai chang caine
Compressed iso (isz) is an open format created by the makers of Ultra ISO and is not supported natively by the Windows OS.
Hello, good job BINGO
but is it the reason why, i have an error at the line 210 :roll: :

Code: Select all

object_fsidir\release() 
I have XP Sp2, Pb v4.10 Beta

Posted: Sun Nov 25, 2007 11:20 am
by DataMiner
@Kwaï chang caïne
On XP sp2 you have to install KB932716 (Image Mastering API v2.0) first.

Posted: Mon Nov 26, 2007 12:46 am
by Dare
Pretty nifty!

Posted: Sat Jan 05, 2008 8:58 pm
by SFSxOI
This is very nice, Thank You :)

Is there some way to get an indication when the iso creation and write to the destination is complete?

how do you add a file with it? AddFile? can't get AddFile to work.

Re: folder to iso (vista , xp/sp2 + KB932716 !)

Posted: Sun Dec 06, 2009 10:01 pm
by Seymour Clufley
I'm running this on XP SP2 (with the KB932716 hotfix installed). An ISO is created with a filesize that seems about right. But when I open the ISO (with WinRAR and with PowerISO), nothing is inside it. Or at least, nothing gets extracted from it.

Re: folder to iso (vista , xp/sp2 + KB932716 !)

Posted: Mon Dec 07, 2009 12:06 am
by SFSxOI
you might look here where I did basically the entire IMAPI thing > http://www.purebasic.fr/english/viewtop ... ilit=IMAPI

Part of this is included, works fine here. Might help. It might be that your not actually adding files to the .iso