uses "shell32.dll"
ShellExecute( hwnd clong, lpOperation cptr,
lpFile cptr, lpParameters cptr,
lpDirectory cptr, nShowCmd clong ) clong
[stdcall "ShellExecuteA"]
endUses
method pushButton(var eventInfo Event)
var
binDocData Binary ; Holds document data
astrFiles Array[] String ; List of documents
fs FileSystem ; Allows file saving
liResult Longint ; ShellExecute result
siDocCount SmallInt ; # of DOC files
strDocName String ; Document Filename
tcDocTable TCursor ; Pointer to BLOB data
endVar
const
BLOB_TABLE = ":work:blobdemo"
DOC_FOLDER = "c:\\temp\\"
endConst
if not tcDocTable.open( BLOB_TABLE ) then
errorShow( "Can't Open " + BLOB_TABLE,
"Use [>>] for more details." )
else
; First, determine the target filename
fs.enumFileList( DOC_FOLDER + "*.doc", astrFiles )
astrFiles.view()
siDocCount = astrFiles.size()
strDocName = DOC_FOLDER + "Doc" +
String( siDocCount + 1 ) +
".doc"
; Now, write the binary data to the file
binDocData = tcDocTable."BlobData"
binDocData.writeToFile( strDocName )
; Finally, print the document
ShellExecute( 0, "print", strDocName, "", "", 3 )
endIf
; Note: Always explicitly close TCursors
if tcDocTable.isAssigned() then
tcDocTable.close()
endIf
endMethod