2009年7月7日 星期二

[Lotus Script]-附件、壓縮

找到了一個可以壓ZIP的DLL檔,可以不用看WinRAR跟7zip的臉色了。

說明:
1.附檔解壓縮後,將該DLL檔放到C:\Windows\ 目錄底下。
2.代理程式使用方式:
※在「Delarations」裡輸入下列程式碼來引用VCZIPSUP.DLL:

Declare Function Zip Lib "VCZIPSUP.DLL" (_
Byval pstrInputDirectory As String, _

Byval pstrFileWildCardSpec As String, _

Byval pstrOutputZipFilename As String, _

Byval iIncludeSubDirs As Integer, _

Byval iKeepFolderStructure As Integer, _

Byval pstrOptions As String) As Long


※在代理程式程式裡呼叫:
Sub Initialize
Dim lRc As Long

lRc = Zip("D:\Temp\Files","*.*", "D:\Temp\MyFirstZipFile.zip",1, 0,"")

End Sub


一、來源路徑
二、來源檔名 (輸入 *.* 可以將該目錄下所有檔案打包壓縮)
三、輸出路徑及檔名
四、未知
五、未知
六、未知

壓縮完成、lRc會返回"0"

==================================================================

另附上修改後的程式。

Sub Initialize
Dim ss As New notessession
Dim workspace As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim Arcobj As NotesEmbeddedObject
Dim doc As NotesDocument
Dim Newitem As Variant, item As Variant
Dim RarPath As String, RarDirName As String, RarFileName As String
Dim result As Integer, RarFinal As String,oName As String,lRc As Long

Set uidoc = workspace.CurrentDocument
Set doc = uidoc.Document

RarPath = "D:\Tmp\ZIP\"

If doc.HasEmbedded Then
RarDirName = Format$(Now(), "hhnnss")
Mkdir RarPath & RarDirName
RarFinal = RarPath & RarDirName

If Not uidoc.EditMode Then uidoc.EditMode = True
Call uidoc.Save

Set item = doc.GetFirstItem("Body")
Forall embobj In item.EmbeddedObjects
oName= embobj.name
Call embobj.ExtractFile( RarFinal & "\\" & oName)
Call embobj.remove
End Forall
Call doc.save(True, False)

%REM
result = Shell("C:\Program Files\7-Zip\7z.exe a " & RarFinal & ".zip" & " " & RarFinal , 1)
Dim ii As Long
For ii = 1 To 10000000
Next
%END REM
lRc = Zip(RarFinal,oName,RarFinal & ".zip",1, 0,"")

Set Newitem = doc.GetFirstItem("Body")
Set Arcobj = Newitem.EmbedObject(EMBED_ATTACHMENT, "", RarFinal & ".zip")
'Set Arcobj = Newitem.EmbedObject(EMBED_ATTACHMENT, "", "D:\Tmp\ZIP\À£.zip")
Call doc.Save( True, True )
Call uidoc.Save

Dim newdoc As New notesdocument( ss.CurrentDatabase )
Set newdoc = doc
Call uidoc.Close
Call workspace.EditDocument(True, newdoc)

Kill RarFinal & ".zip"
'Rmdir RarFinal
Else
Print Now()+" No Embedded Object"
End If
End Sub




--
---- 書本上查的到的東西 ---- 不用去背他 ----

沒有留言: