[syntax="ls"]Const wAPIModule = "NNOTES" ' Windows/32
Type BlockID
hPool As Long
Block As Integer
End Type
Declare Private Function NSFDbOpen Lib wAPIModule Alias "NSFDbOpen" _
( Byval PathName As String, DbHandle As Long) As Integer
Declare Private Function NSFDbClose Lib wAPIModule Alias "NSFDbClose" _
( Byval DbHandle As Long) As Integer
Declare Private Function NSFNoteOpen Lib wAPIModule Alias "NSFNoteOpen" _
( Byval hDB As Long, Byval NoteID As Long, Byval F As Integer, hNT As Long) As Integer
Declare Private Function NSFNoteClose Lib wAPIModule Alias "NSFNoteClose" _
( Byval hNT As Long) As Integer
Declare Private Function NSFNoteUpdate Lib wAPIModule Alias "NSFNoteUpdate" _
( Byval hNT As Long, Byval F As Integer) As Integer
Declare Function NSFItemInfo Lib wAPIModule Alias "NSFItemInfo" _
( Byval hNT As Long, Byval N As String, Byval nN As Integer _
, iB As BlockID, D As Integer, vB As BlockID, nV As Long) As Integer
Declare Function NSFItemDelete Lib wAPIModule Alias "NSFItemDelete" _
( Byval hNT As Long, Byval N As String, Byval nN As Integer) As Integer
Declare Private Function NSFItemAppend Lib wAPIModule Alias "NSFItemAppend" _
( Byval hNT As Long, Byval F As Integer, Byval N As String, Byval nN As Integer _
, Byval T As Integer, Byval V As Long, Byval nV As Long) As Integer
Declare Private Function OSLockObject Lib wAPIModule Alias "OSLockObject" _
( Byval H As Long) As Long
Declare Private Sub OSUnlockObject Lib wAPIModule Alias "OSUnlockObject" _
( Byval H As Long)
Declare Private Function OSMemAlloc Lib wAPIModule Alias "OSMemAlloc" _
( Byval T As Integer, Byval S As Long, hM As Long) As Integer
Declare Private Function OSMemFree Lib wAPIModule Alias "OSMemFree" _
( Byval hM As Long) As Integer
Declare Private Function OSPathNetConstruct Lib wAPIModule Alias "OSPathNetConstruct" _
( Byval NullPort As Long, Byval Server As String, Byval FIle As String, Byval PathNet As String) As Integer
Sub SetFooterText(db As NotesDatabase, noteID As String, text As String)
Const item = "$Footer"
np$ = Space(1024)
OSPathNetConstruct 0, db.Server, db.FilePath, np$
Dim hDB As Long
NSFDbOpen np$, hDB
If hDB = 0 Then
Messagebox "Can't open database", 16
Exit Sub
End If
Dim hNT As Long
NSFNoteOpen hDB, Clng("&H" & noteID), 0, hNT
If hNT = 0 Then
Messagebox "Can't open note " & noteID, 16
Else
t$ = text & Chr$(0)
If Len(t$) And 1 Then t$ = t$ & Chr$(0)
data& = 42 + Len(t$)
Dim hM As Long
OSMemAlloc 0, data&, hM
q& = OSLockObject(hM)
Dim iB As BlockID, vB As BlockID
NSFItemInfo hNT&, item, Len(item), iB, dt%, vB, nv&
If vB.hPool = 0 Then
Messagebox "Can't open item " & item, 16
Else
p& = OSLockObject(vB.hPool) + vB.Block
Peek v%, p& + 2, 2
If v% = &HFF8E Then
MemCopy q&, p& + 2, 41
Poke q& + 2, data&, 2
Poke q& + 41, Len(t$), 2
PokeString q& + 43, t$, Len(t$)
OSUnlockObject vB.hPool
NSFItemDelete hNT, item, Len(item)
NSFItemAppend hNT, 0, item, Len(item), 1, q&, data&
NSFNoteUpdate hNT, 0
Else
OSUnlockObject vB.hPool
Messagebox "Item is not a header/footer", 16
End If
End If
OSUnlockObject hM
OSMemFree hM
End If
NSFNoteClose hNT
NSFDbClose hDB
End Sub[/syntax]