转自:http://searchdomino.techtarget.com/tip/Hide-code-in-Script-Library
Do you want protect your work? Create a button in a form, and copy the code below:
Note: In the Script Library there are two types of code:
1 - not compiled (that I can see, contained in $ScriptLib field)
2 - compiled (that I can not see, contained in $ScriptLib_O filed)
When I save a Script Library the content in $ScriptLib is Compiled in $ScriptLib_O field and the Lotus database use the last one.
This tip deletes the field $ScriptLib and leaves the field $ScriptLib_O, so that the library is available to use but I can't see the code.
'Declarations (button) Const NOTE_CLASS_FILTER = &H0200 Declare Private Function WinNSFDbOpen Lib "nnotes" Alias "NSFDbOpen"
( Byval dbname As Lmbcs String, dbhandle As Long ) As Integer Declare Private Function WinNSFDbGetModifiedNoteTable Lib "nnotes"
Alias "NSFDbGetModifiedNoteTable"( Byval dbhandle As Long, Byval
classmask As Integer, Byval startdate As Double, endate As Double,
returntablehandle As Long ) As Integer Declare Private Function WinIDEntries Lib "nnotes"Alias "IDEntries"(
Byval tablehandle As Long ) As Long Declare Private Function WinIDScan Lib "nnotes" Alias "IDScan"( Byval
tablehandle As Long, Byval firstbool As Integer, returnid As Long) As Integer Declare Private Function WinOSMemFree Lib "nnotes" Alias "OSMemFree"
(Byval handle As Long) As Integer Declare Private Function WinNSFDbClose Lib "nnotes" Alias "NSFDbClose"
( Byval dbhandle As Long) As Integer Declare Private Sub WinTimeConstruct Lib "nnotes" Alias "TimeConstruct"
( Byval adate As Long, Byval atime As Long, datetime As Double) 'on Click Dim session As New NotesSession Dim db As NotesDatabase Dim dbhandle As Long Dim path As String Dim begindate As Double Dim enddate As Double Dim idtablehandle As Long Dim noteid As Long Dim count As Integer Dim note As Variant Set db = session.currentDatabase If db.server = "" Then path = db.filepath Else path = db.server & "!!" & db.filepath End If Call winNSFDBOpen(path, dbhandle) Call winTimeConstruct( &hFFFFFFFF, &hFFFFFFFF, begindate ) On Error Goto errSub Call winNSFDbGetModifiedNoteTable( dbhandle, NOTE_CLASS_FILTER, begindate , enddate , idtablehandle ) If winIDEntries( idtablehandle) <>0 Then If winIDScan( idtablehandle, True, noteid ) Then Do While winIDScan( idtablehandle, False, noteid ) Set note = db.getDocumentByID(Hex$( noteId)) If Not note Is Nothing Then If note.getItemValue( "$Flags")(0) Like "*[s]*"Then If note.hasItem("$ScriptLib") Then Call note.RemoveItem("$ScriptLib") Call note.save(True, False, True) End If End If End If Loop End If End If exitSub: If idtablehandle <> 0 Then Call winOsMemFree( idtablehandle) End If If dbhandle <> 0 Then Call winNSFDbClose( dbhandle) End If Exit Sub errSub: Resume exitSub