Author | Topic: ImAPI v2.x for Xbase++ | |
---|---|---|
AUGE_OHR | ImAPI v2.x for Xbase++ on Thu, 05 Aug 2010 09:02:51 +0200 hi, this VbScript run fine on XP (with http://support.microsoft.com/kb/932716 ) or Vista / Win7 *** Code *** ' 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 = 0 ' Second drive on the system Path = "c:\ALASKA" ' 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.ChooseImageDefaults(recorder) ' 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 *** eof *** now i try same with Xbase++ *** Code *** #include "Xbp.ch" #include "Appevent.ch" #define CRLF CHR(13)+CHR(10) #pragma library( "ascom10.lib" ) PROCEDURE APPSYS RETURN PROCEDURE MAIN LOCAL lExit := .F. LOCAL nEvent, mp1, mp2, oXbp LOCAL oDlg,oBtn LOCAL aPos := { 0, 0} LOCAL aSize := {300,200} oDlg := XbpDialog():new(AppDeskTop(),,aPos,aSize) oDlg:title := "Xbase++ ImAPI Burning CD R/W" oDlg:tasklist := .T. oDlg:close := {|| lExit := .T. } oDlg:create() CenterControl( oDlg ) oBtn := XbpPushButton():new( oDlg:drawingArea ,, {10,10}, {100,30} ) oBtn:caption := "push me" oBtn:create() oBtn:activate := {|| BurnImAPI(oDlg) } SetAppWindow(oDlg) SetAppFocus(oDlg) SetAppFocus(oBtn) nEvent := 0 DO WHILE !lExit nEvent := AppEvent( @mp1, @mp2, @oXbp ) DO CASE CASE nEvent = xbe_None OTHERWISE oXbp:handleEvent( nEvent, mp1, mp2 ) ENDCASE ENDDO RETURN PROCEDURE BurnImAPI(oDlg) LOCAL Index LOCAL Recorder LOCAL Path LOCAL Stream LOCAL g_DiscMaster LOCAL uniqueId LOCAL FSI LOCAL TreeDir LOCAL dataWriter LOCAL result LOCAL nStart LOCAL nEnde Index := 0 Path := "c:\ALASKA" {2735412E-7F64-5B0F-8F00-5D77AFBE261E} g_DiscMaster := CreateObject("{2735412E-7F64-5B0F-8F00-5D77AFBE261E}") * g_DiscMaster := CreateObject("IMAPI2.MsftDiscMaster2.1") * g_DiscMaster := AutomationObject():create("{2735412E-7F64-5B0F-8F00-5D77AFBE261E}") * g_DiscMaster := AutomationObject():create("IMAPI2.MsftDiscMaster2.1") * g_DiscMaster := XbpActiveXControl():new(oDlg,,{0,0},{1,1}) * g_DiscMaster:CLSID := "IMAPI2.MsftDiscMaster2.1" * g_DiscMaster:CLSID := "{2735412E-7F64-5B0F-8F00-5D77AFBE261E}" * g_DiscMaster:create() IF NIL = g_DiscMaster msgbox("ERROR mit IMAPI2") ELSE {2735412D-7F64-5B0F-8F00-5D77AFBE261E} Recorder := CreateObject("IMAPI2.MsftDiscRecorder2") uniqueId := g_DiscMaster:Item(index) Recorder:InitializeDiscRecorder( uniqueId ) {2C941FC5-975B-59BE-A960-9A2A262853A5} FSI := CreateObject("IMAPI2FS.MsftFileSystemImage") TreeDir := FSI:setProperty("Root") {2735412A-7F64-5B0F-8F00-5D77AFBE261E} dataWriter := CreateObject ("IMAPI2.MsftDiscFormat2Data") dataWriter:recorder := Recorder dataWriter:ClientName := "IMAPIv2 TEST" FSI:ChooseImageDefaults(Recorder) TreeDir:AddTree( Path, .F.) result := FSI:CreateResultImage() Stream := result:ImageStream Msgbox("Writing content to disc...") nStart := Seconds() dataWriter:write(Stream) nEnde := Seconds() Msgbox("----- Finished writing content -----"+CRLF+; LTRIM(STR( nEnde - nStart ))+" Seconds " ) ENDIF RETURN *** eof *** but it do not work with Xbase++ ... greetings by OHR Jimmy | |
Osvaldo Ramirez | Re: ImAPI v2.x for Xbase++ on Thu, 05 Aug 2010 07:59:09 -0600 Dear Jim >> dataWriter:write(Stream) >> I dont know, but Maybe if dataWriter:write(Stream) > 0 success else not success endif or ... dataWriter:write(Stream) dataWriter:closesession(Stream) Maybe Regards Osvaldo | |
AUGE_OHR | Re: ImAPI v2.x for Xbase++ on Thu, 05 Aug 2010 19:47:21 +0200 hi, > I dont know, but Maybe i did not come to that Place. it is 1st Line with CreateObject() which "fail" i can not access it via CreateObject(), AutomationObject() or XbpActiveXControl() 1.) and 2.) give NIL while 3.) crash ... as i say , try VbScript and you will see that CLSID etc. is ok and work, but Xbase++ fail. it also work with WinDEV and "other" Compiler, so it is Xbase++. i always say, that Xbase++ v1.9x activeX is not "complett". ImAPI show again that only 50% of activeX can be used by Xbase++ WHEN will Alaska fix it and give us "real" activeX Power for Xbase++ greetings by OHR Jimmy | |
AUGE_OHR | Re: ImAPI v2.x for Xbase++ on Mon, 09 Aug 2010 18:46:29 +0200 > but it do not work with Xbase++ ... with Xbase++ Add-on YUKON ( http://www.knowlexbase.com/en/software/downloads/yukon/index.html ) i can access IMAPI with this Code *** Code *** #include "yukonCDB.ch" PROCEDURE Main LOCAL aDir := Directory( "*.prg" ) LOCAL i, imax := Len( aDir ) LOCAL oCdBurner, oDisc, aDevices oCdBurner := CdBurner():new( CD_DATA ) vs CD_AUDIO oCdBurner:create() get available CD burning devices aDevices := oCdBurner:listDevices() IF Empty( aDevices ) ? "No CD burning device available" oCdBurner:destroy() QUIT ENDIF select/activate a device ? "Selecting:", aDevices[1] oCdBurner:selectDevice( aDevices[1] ) IF oCdBurner:isDisc() <> 1 ? "No CD in CD drive" oCdBurner:destroy() QUIT ENDIF assign your callback code blocks oCdBurner:onAddProgress := {|o,x,y| QOut("onAddProgress ",x,y) } oCdBurner:onBlockProgress := {|o,x,y| QOut("onBlockProgress",x,y) } oCdBurner:onBurnComplete := {|o,x | QOut("onBurnComplete ",x) } oCdBurner:onClosingDisc := {|o,x | QOut("onClosingDisc ",x) } oCdBurner:onEraseComplete := {|o,x | QOut("onEraseComplete",x) } oCdBurner:onPnPActivity := {|o | QOut("onPnPActivity ") } oCdBurner:onPreparingBurn := {|o,x | QOut("onPreparingBurn",x) } oCdBurner:onQueryCancel := {|o | QOut("onQueryCancel "),.F. } oCdBurner:onTrackProgress := {|o,x,y| QOut("onTrackProgress",x,y) } get the CD Disc object that receives files to burn oDisc := oCdBurner:getDisc() add all files to the staging area AEval( aDir, {|a| oDisc:addFile( a[1] ) } ) Burn to CD. Burning progress is reported via callback code blocks oCdBurner:recordDisc( .T. ) .F. == simulate burn .T. == burn CD Burning can be interrupted via the :onQueryCancel callback Finished oCdBurner:ejectDisc() oCdBurner:destroy() RETURN *** Eof *** so if a Add-on can do it, why Xbase++ can not do it "pure" with it´s ActiveX Class ??? greetings by OHR Jimmy |